seaborn不同于HTML颜色的cmap调色板

2024-04-28 04:29:12 发布

您现在位置:Python中文网/ 问答频道 /正文

Seaborn可以选择a pallet from any HTML color,如下所示:

cmap = sns.light_palette("royalblue", as_cmap=True)

有没有一种方法可以使用HTML颜色选择/创建不同的cmap?比如:

cmap = sns.diverging_palette("color_a","color_b", as_cmap=True)

Tags: 方法fromtrue颜色htmlasanyseaborn
2条回答

否,因为diverging_colormap的点是端点仅在色调上不同,并且具有相同的饱和度和亮度值。对于两种任意的html颜色来说,情况并非如此

您可以将端点和中间值传递给blend_palette

sns.palplot(sns.blend_palette(["dodgerblue", ".95", "crimson"], 9))

enter image description here

但是请注意,这样一个颜色贴图的感知属性将不太好

您可以使用sns.diverging_palettehttps://seaborn.pydata.org/generated/seaborn.diverging_palette.html),方法是将HSLuv system中的颜色值设置为前两个参数,设置hue,例如

sns.palplot(sns.diverging_palette(200, 55, s=80, l=55, n=9))
sns.palplot(sns.diverging_palette(2, 165, s=80, l=55, n=9))

enter image description hereenter image description here

相关问题 更多 >