sns各种样式的图中参数palette可选的值

目录

1.分类色板(Qualitative color palettes: good for representing categorical data)

2.连续色板(sequential palettes: good for representing numeric data)

3.离散色板(diverging palettes: good for representing numeric data with a categorical boundary)


seaborn库里的很多类型绘图都可以传入一个叫palette的参数,这个参数的含义就是给你的图中值应用不同的调色板,每个调色板有自己独特的hue,saturation和luminance(这里的hue不是绘图函数中要传入的参数hue)。官方文档的链接:http://seaborn.pydata.org/tutorial/color_palettes.html

palette一共有三种类型的色板,分别是分类色板,连续色板和离散色板。

1.分类色板(Qualitative color palettes: good for representing categorical data)

官方文档的解释:Qualitative palettes are well-suited to representing categorical data because most of their variation is in the hue component. 

翻译过来的大意就是:Qualitative调色板,也可以说成是类型调色板,它对于分类数据的显示很有帮助。当你想要区别不连续的且内在没有顺序关系的数据时,这个方式是最好的。

我们可以用下面的方式看看不同调色板参数展示出来的效果:

import seaborn as sns
import matplotlib.pyplot as plt

current_palette = sns.color_palette()
sns.palplot(current_palette)
plt.show()

这是默认的色板,也就是deep模式的色板。

seaborn有6种matplotlib不同类型的色板,分别是:deepmutedpastelbrightdarkcolorblind.

还可以用hls色空间来自定义色板颜色,如sns.palplot(sns.hls_palette(8, l=.3, s=.8))这种。

2.连续色板(sequential palettes: good for representing numeric data)

官方文档的解释:Because they are intended to represent numeric values, the best sequential palettes will be perceptually uniform, meaning that the relative discriminability of two colors is proportional to the difference between the corresponding data values.

作为调色板的第二大类,这种调色板对于有从低(无意义)到高(有意义)范围过度的数据非常适合。seaborn自带四种成型色板:“rocket”, “crest”,“mako”,“flare”。

我们来看看四种色板:

current_palette = sns.color_palette('rocket')
sns.palplot(current_palette)
plt.show()

 用在离散数据时是这样的:

 用于连续数据时是这样的:

 同样,看看其他三个色板:

 mako

flare

crest

同时还可以使用matplotlib里的两种类型:"magma"和"viridis"。

 按照matplotlib的惯例,在颜色后加上_r就是reversed模式:

current_palette = sns.color_palette('rocket_r')
sns.palplot(current_palette)
plt.show()

3.离散色板(diverging palettes: good for representing numeric data with a categorical boundary)

官方文档:The third class of color palettes is called “diverging”. These are used for data where both large low and high values are interesting and span a midpoint value (often 0) that should be demphasized. The rules for choosing good diverging palettes are similar to good sequential palettes, except now there should be two dominant hues in the colormap, one at (or near) each pole. It’s also important that the starting values are of similar brightness and saturation.

划重点,一般这种值的范围都会跨越重点,比如0点。

自带两种成型色板:vlag和icefire。

vlag:

icefire:

 还可以定制离散色板,这里就不赘述了。

 

 

  • 14
    点赞
  • 69
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值