sns.barplot参数_cad文字样式设置参数[通俗易懂]

sns.barplot参数_cad文字样式设置参数[通俗易懂]目录1.分类色板(Qualitativecolorpalettes:goodforrepresentingcategoricaldata)2.连续色板(sequentialpalettes:g

目录

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()

sns.barplot参数_cad文字样式设置参数[通俗易懂]

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

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

sns.barplot参数_cad文字样式设置参数[通俗易懂]

还可以用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()

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

sns.barplot参数_cad文字样式设置参数[通俗易懂]

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

sns.barplot参数_cad文字样式设置参数[通俗易懂]

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

 mako

sns.barplot参数_cad文字样式设置参数[通俗易懂]

sns.barplot参数_cad文字样式设置参数[通俗易懂]

flare

sns.barplot参数_cad文字样式设置参数[通俗易懂]

sns.barplot参数_cad文字样式设置参数[通俗易懂]

crest

sns.barplot参数_cad文字样式设置参数[通俗易懂]

sns.barplot参数_cad文字样式设置参数[通俗易懂]

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

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

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

sns.barplot参数_cad文字样式设置参数[通俗易懂]

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:

sns.barplot参数_cad文字样式设置参数[通俗易懂]

icefire:

sns.barplot参数_cad文字样式设置参数[通俗易懂]

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

 

 

今天的文章sns.barplot参数_cad文字样式设置参数[通俗易懂]分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/87246.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注