最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python可視化學(xué)習(xí)之seaborn調(diào)色盤

 更新時間:2022年02月24日 16:53:27   作者:qq_21478261  
seaborn是在matplotlib基礎(chǔ)上封裝的,所以matplotlib的調(diào)色盤seaborn都可以使用。本文系統(tǒng)介紹seaborn調(diào)色盤,相較于matplotlib,有諸多不同,需要的可以參考一下

1、color_palette() 函數(shù)

該函數(shù)是seaborn選取顏色關(guān)鍵函數(shù)

color_palette() will accept the name of any seaborn palette or matplotlib colorma

語法:seaborn.color_palette(palette=None, n_colors=None, desat=None)

import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(dpi=250)
sns.palplot(sns.color_palette())#輸出默認顏色

print(sns.color_palette())#返回默認顏色元組組成的list

#palette,傳入colormap名稱
sns.palplot(sns.color_palette(palette='Accent'))#使用matplotlib中的colormap

#n_colors
sns.palplot(sns.color_palette(n_colors=21))#返回顏色種類,超過了自動循環(huán)

# desat
sns.palplot(sns.color_palette(n_colors=21,
                             desat=0.2))#設(shè)置顏色飽和度

#with
plt.figure(dpi=100)
with sns.color_palette(n_colors=21):#循環(huán)使用色盤
   _ = plt.plot(np.c_[np.zeros(21), np.arange(21)].T)

#傳入hex 格式顏色號給sns.color_palette
flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
sns.palplot(sns.color_palette(flatui))

#顏色使用
plt.figure(dpi=100)
 
plt.subplot(1,2,1)
plt.bar([1,2,3],[1,2,3],color=sns.color_palette()[0])#取一種顏色
 
plt.subplot(1,2,2)
plt.bar([1,2,3],[1,2,3],color=sns.color_palette()[0:3])#取三種顏色

2、 seaborn可用調(diào)色盤

分三大類:‘sequential’(漸變色), ‘diverging’(不可描述,看下圖), ‘qualitative’(各種顏色區(qū)分鮮明)

choose_colorbrewer_palette函數(shù)

該函數(shù)可以預(yù)覽各種顏色盤, 只能在jupyter notebook中使用。

下面詳細介紹上面三類顏色。

Qualitative color palettes

to distinguish discrete chunks of data that do not have an inherent ordering,分如下幾類:

1、deep, muted, pastel, bright, dark, colorblind

2、hls

3、husl

4、palettable 5、xkcd

6、傳入顏色list

#deep, muted, pastel, bright, dark, colorblind
for i in list('deep, muted, pastel, bright, dark, colorblind'.split(', ')): 
    print(i,end='\t')
    sns.palplot(sns.color_palette(palette=i))  

從上到下依次為:deep, muted, pastel, bright, dark, colorblind

# hls
 
sns.palplot(sns.color_palette(palette='hls'))
sns.palplot(sns.hls_palette(8, l=.3, s=.8))

#husl
 
sns.palplot(sns.color_palette(palette='husl'))
sns.palplot(sns.color_palette("husl", 8))

import palettable#python palettable庫
sns.palplot(sns.color_palette(palette=palettable.colorbrewer.qualitative.Dark2_7.mpl_colors))#使用palettable中的colormap
sns.palplot(sns.color_palette(palette=palettable.scientific.sequential.Nuuk_7.mpl_colors))

#xkcd
plt.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,詳細可參考 :Python可視化學(xué)習(xí)之matplotlib內(nèi)置單顏色

#傳入顏色list給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"這類

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、傳統(tǒng)色的漸變色,light_palette()、dark_palette() 

#"Blues"這類漸變色
sns.palplot(sns.color_palette("Blues"))
sns.palplot(sns.color_palette("Blues_d"))#_d表示顯示該顏色的深色系(“dark” palettes by appending “_d”)
sns.palplot(sns.color_palette("Blues_r"))

# cubehelix
sns.palplot(sns.color_palette("cubehelix", 8))
sns.palplot(sns.color_palette("ch:2.5,-.2,dark=.3"))#使用cubehelix接口制作顏色
sns.palplot(sns.cubehelix_palette(8, start=2, rot=0, dark=0, light=.95, reverse=True))

#light_palette
sns.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, n=9))
sns.palplot(sns.diverging_palette(150, 275, s=80, l=55, n=9))
sns.palplot(sns.diverging_palette(250, 15, s=75, l=40,
                                  n=9, center="dark"))

到此這篇關(guān)于Python可視化學(xué)習(xí)之seaborn調(diào)色盤的文章就介紹到這了,更多相關(guān)Python seaborn調(diào)色盤內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

清丰县| 社会| 岱山县| 二手房| 元谋县| 运城市| 肥乡县| 波密县| 乌兰浩特市| 永修县| 棋牌| 荣昌县| 上犹县| 阿图什市| 油尖旺区| 潜江市| 蕲春县| 遂溪县| 新绛县| 电白县| 浏阳市| 陈巴尔虎旗| 大理市| 诸城市| 西丰县| 邹平县| 新泰市| 阜阳市| 内丘县| 茂名市| 巴里| 龙胜| 巴青县| 汾西县| 大渡口区| 毕节市| 顺昌县| 洪泽县| 邵阳县| 大石桥市| 宜昌市|