In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you how to use sns.set_palette() in Seaborn in Python. The content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn this article "How to use sns.set_palette() in Seaborn in Python".
sns.set_palette()
This feature is handy if you want to customize the default palette to your favorite color combinations. We can use color mapping in Matplotlib. Here is a selection from the color library. Let's change the palette to "rainbow" and look at the graph again:
#Change default palette sns.set_palette ('rainbow ')#plot plt.figure(figsize=(9, 5))sns.scatterplot(data=df, x='body_mass_g', y='bill_length_mm', alpha=0.7, hue='species', size='gender')plt.legend(loc='upper right', bbox_to_anchor=(1.3, 1));
If you can't find a Matplotlib color map you like, you can manually select colors to create your own unique palette. One way to create your own palette is to pass a list of color names to a function, as shown in the following example.
#Change default palette sns.set_palette(<$'green ', ' purple','red')#Figure plt.figure(figsize=(9, 5))sns.scatterplot(data=df, x='body_mass_g', y='bill_length_mm', alpha=0.7, hue='species', size='gender')plt.legend(loc='upper right', bbox_to_anchor=(1.3, 1));
If the color name doesn't capture what you're after well, you can build your own palette using hex colors to access a wider range of options (over 16 million colors!). Here are my favorite resources to find a hex custom palette. Let's look at an example:
#Change default palette sns.set_palette(['#62C370','#FFD166','#EF476F'])#Figure plt.figure(figsize=(9, 5))sns.scatterplot(data=df, x='body_mass_g', y='bill_length_mm', alpha=0.7, hue='species', size=' gender') plt.legend(loc='upper right', bbox_to_anchor=(1.3, 1)); above is "How to use sns.set_palette() in Seaborn in Python" All the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.