seaborn.cubehelix_palette#

seaborn.cubehelix_palette(n_colors=6, start=0, rot=0.4, gamma=1.0, hue=0.8, light=0.85, dark=0.15, reverse=False, as_cmap=False)#

從立方螺旋系統建立一個連續色調的調色盤。

這會產生一個亮度線性遞減(或遞增)的色彩圖。這表示如果列印成黑白或由色盲人士檢視,資訊將會被保留。「cubehelix」也可以作為基於 matplotlib 的調色盤,但這個函數讓使用者可以更精確地控制調色盤的外觀,並且有一組不同的預設值。

除了使用此函數外,也可以在 seaborn 中使用以 ch: 開頭並包含其他參數的字串來產生立方螺旋調色盤(例如 "ch:s=.25,r=-.5")。

參數:
n_colorsint

調色盤中的顏色數量。

startfloat, 0 <= start <= 3

螺旋起點的色調值。

rotfloat

在調色盤範圍內,繞色輪旋轉的次數。

gammafloat 0 <= gamma

強調深色 (gamma < 1) 或淺色 (gamma > 1) 的非線性。

huefloat, 0 <= hue <= 1

顏色的飽和度。

darkfloat 0 <= dark <= 1

調色盤中最深色的強度。

lightfloat 0 <= light <= 1

調色盤中最淺色的強度。

reversebool

如果為 True,則調色盤會從深色到淺色。

as_cmapbool

如果為 True,則傳回 matplotlib.colors.ListedColormap

回傳值:
palette

RGB 元組列表或 matplotlib.colors.ListedColormap

另請參閱

choose_cubehelix_palette

啟動互動式小工具來選擇立方螺旋調色盤的參數。

dark_palette

建立一個具有深色低值的連續調色盤。

light_palette

建立一個具有淺色低值的連續調色盤。

參考文獻

Green, D. A. (2011). “A colour scheme for the display of astronomical intensity images”. Bulletin of the Astromical Society of India, Vol. 39, p. 289-295.

範例

傳回具有預設參數的離散調色盤

sns.cubehelix_palette()

增加顏色數量

sns.cubehelix_palette(8)

傳回連續色彩圖,而非離散調色盤

sns.cubehelix_palette(as_cmap=True)
seaborn_cubehelix color map

變更螺旋的起始點

sns.cubehelix_palette(start=2)

變更螺旋中的旋轉量

sns.cubehelix_palette(rot=.2)

反向旋轉

sns.cubehelix_palette(rot=-.2)

對亮度斜坡套用非線性

sns.cubehelix_palette(gamma=.5)

增加顏色的飽和度

sns.cubehelix_palette(hue=1)

變更起點和終點的亮度

sns.cubehelix_palette(dark=.25, light=.75)

反轉亮度斜坡的方向

sns.cubehelix_palette(reverse=True)