Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use sns.set_context () for Seaborn in Python

Shulou Source: shulou.com Published: 2022-06-01 05:45:03 09月23日 Update

The editor will share with you how Seaborn in Python uses sns.set_context (). I hope you will get something after reading this article. Let's discuss it together.

Sns.set_context ()

In the previous figure, the label size looked very small. If you don't like the default settings, we can use sns.set_context () to change the context parameters.

I use this function mainly to control the default font size of the labels in the drawing. By changing the default values, we can save time without having to resize fonts for different elements of a single drawing (such as axis labels, headings, legends). Let's change the context to "talk" and look at the figure:

# default context change sns.set_context ('talk') # figure plt.figure (figsize= (9,5)) sns.scatterplot (data=df, xylene / bodyweight massages, alpha=0.7 / hue='species', size='gender') plt.legend (loc='upper right', bbox_to_anchor= (1.3,1))

It's easier to recognize, isn't it? Another option you can try is "poster", which will increase the default size or more.

After reading this article, I believe you have some understanding of "how Seaborn in Python uses sns.set_context ()". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Tags: Context size label font more article drawing different element function single parameter legend finished size time title knowledge industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Information Docker Linux vpn