2017-03-08 62 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