Seaborn light_调色板定制长度

2024-09-25 10:19:38 发布

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

我正在尝试使用自定义长度的seaborn制作一个顺序调色板。seaborn同时提供了light_palette和{},它们看起来很像我想要的,但是我需要一个自定义的步骤长度。我还需要匹配seaborn的默认配色方案。在

import seaborn as sns
sns.palplot(sns.light_palette(sns.color_palette()[0]))

<code>light_palette</code> of constant length

我尝试了几种解决方案:

尝试1-使用seaborn.cubehelix_palette,但是我无法匹配seaborn.color_palette()提供的颜色

^{pr2}$

Attempt 1 output

尝试2-使用seaborn.diverging_palette的一半,但我也无法使颜色匹配。默认的配色方案会显示一种蓝色,即RGB(76114176)或hex(#4C72B0)或HSL(217°40%49%),但当输入这些参数时,我得到了错误的颜色。在

import seaborn as sns
sns.palplot(sns.diverging_palette(217.,217.,n=7,s=40,l=49))

Attempt 2 Bad Plot


Tags: import顺序颜色as方案步骤seaborncolor