2017-03-08 80 views
1

我正在尝试使用自定义长度的seaborn进行顺序调色板。 seaborn同时提供了light_palettedark_palette,看起来与我想要的非常相似,但我需要自定义长度的步骤。我还需要匹配seaborn的默认配色方案。Seaborn light_palette自定义长度

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

import seaborn as sns 
sns.palplot(sns.cubehelix_palette(7,start=1,rot=0,dark=0.22,light=0.8)) 

Attempt 1 output

提供的颜色

尝试2 - 使用seaborn.diverging_palette的一半,但我无法使颜色匹配。默认的颜色方案会输出RGB(76,114,176)或十六进制(#4C72B0)或HSL(217°40%49%)的蓝色,但输入这些参数时会出现错误的颜色。

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

​​

+0

是什么 “的步骤长度” 是什么意思?颜色数量?每种颜色之间的感知距离? –

回答

2

您可以通过调用调色板指定这个号码获得与N颜色调色板。

sns.palplot(sns.light_palette(sns.color_palette()[0],N)) 

enter image description here