In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you the "sample analysis of the seaborn palette in Python", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let the editor lead you to study and study the "sample analysis of the seaborn palette in Python".
1. Color_palette () function
This function is the key function for seaborn to select color.
Color_palette () will accept the name of any seaborn palette or matplotlib colorma
Syntax: seaborn.color_palette (palette=None, n_colors=None, desat=None)
Import seaborn as snsimport matplotlib.pyplot as pltplt.figure (dpi=250) sns.palplot (sns.color_palette ()) # output default color
Print (sns.color_palette ()) # returns the list of the default color tuple
# palette, pass in the colormap name sns.palplot (sns.color_palette (palette='Accent')) # use the colormap in matplotlib
# n_colorssns.palplot (sns.color_palette (n_colors=21)) # returns the color category, which exceeds the automatic loop
# desatsns.palplot (sns.color_palette (n_colors=21, desat=0.2)) # set color saturation
# withplt.figure (dpi=100) with sns.color_palette (n_colors=21): # Recycle color disk _ = plt.plot (np.c_ [np.zeros (21), np.arange (21)] .T)
# pass the hex format color number to sns.color_paletteflatui = ["# 9b59b6", "# 3498db", "# 95a5a6", "# e74c3c", "# 34495e", "# 2ecc71"] sns.palplot (sns.color_palette (flatui))
# Color use plt.figure (dpi=100) plt.subplot (1mine2jue 1) plt.bar ([1dje 2je 3], [1je 2je 3], color=sns.color_palette () [0]) # take a color plt.subplot (1m 2m 2) plt.bar ([1m 2je 3], [1m 2je 3], color=sns.color_palette () [0:3]) # take three colors
2. Seaborn available color palette
There are three main categories: 'sequential' (gradient),' diverging' (indescribable, see below), and 'qualitative' (distinct colors)
Choose_colorbrewer_palette function
This function can preview a variety of color plates and can only be used in jupyter notebook.
The above three types of colors are described in detail below.
Qualitative color palettes
To distinguish discrete chunks of data that do not have an inherent ordering is divided into the following categories:
1 、 deep, muted, pastel, bright, dark, colorblind
2 、 hls
3 、 husl
4 、 palettable 5 、 xkcd
6. Input color list
# deep, muted, pastel, bright, dark, colorblindfor i in list ('deep, muted, pastel, bright, dark, colorblind'.split (','): print (sns.color_palette (palette=i))
From top to bottom are: deep, muted, pastel, bright, dark, colorblind
# hls sns.palplot (sns.color_palette (palette='hls')) sns.palplot (sns.hls_palette (8, lumb.3, sq.8))
# husl sns.palplot (sns.color_palette (palette='husl')) sns.palplot (sns.color_palette ("husl", 8))
Import palettable#python palettable library sns.palplot (sns.color_palette (palette=palettable.colorbrewer.qualitative.Dark2_7.mpl_colors)) # uses colormapsns.palplot in palettable (sns.color_palette (palette=palettable.scientific.sequential.Nuuk_7.mpl_colors))
# xkcdplt.plot ([0,1], [0,1], sns.xkcd_rgb ["pale red"], lw=3) plt.plot ([0,1], [0,2], sns.xkcd_rgb ["medium green"], lw=3) plt.plot ([0,1], [0,3], sns.xkcd_rgb ["denim blue"], lw=3)
Xkcd, for more information, please see: matplotlib built-in single color of Python visual learning
# pass color list to ns.xkcd_palette () colors = ["windows blue", "amber", "greyish", "faded green", "dusty purple"] sns.palplot (sns.xkcd_palette (colors))
Sequential color palettes
Is appropriate when data range from relatively low or uninteresting values to relatively high or interesting values
1. "Blues" and so on
2. 'cubehelix',seaborn.cubehelix_palette (n_colors=6, start=0, rot=0.4, gamma=1.0, hue=0.8, light=0.85, dark=0.15, reverse=False, as_cmap=False)
3. Gradient of traditional color, light_palette (), dark_palette ()
# sns.palplot (sns.color_palette ("Blues")) sns.palplot (sns.color_palette ("Blues_d")) # _ d, such as "Blues", indicates the dark color system ("dark" palettes by appending "d") sns.palplot (sns.color_palette ("Blues_r")) showing the color
# cubehelixsns.palplot (sns.color_palette ("cubehelix", 8)) sns.palplot (sns.color_palette ("ch:2.5,-.2,dark=.3")) # use cubehelix interface to make color sns.palplot (sns.cubehelix_palette (8, start=2, rot=0, dark=0, light=.95, reverse=True))
# light_palettesns.palplot (sns.light_palette ("seagreen", reverse=True)) sns.palplot (sns.light_palette ((260,75,60), input= "husl"))
Diverging color palettes
For data where both large low and high values are interesting.
1. Diverging_palette ()
Sns.palplot (sns.color_palette ("coolwarm", 7))
Sns.palplot (sns.diverging_palette (240,10,9) sns.palplot (sns.diverging_palette (150,275,80,55,9) sns.palplot (sns.diverging_palette (250,15,75,40,299, center= "dark")
The above is all the contents of the article "sample Analysis of the seaborn palette in Python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.