0.12.0.dev0
  • Gallery
  • Tutorial
  • API
  • Site
      • 发行说明
      • 安装
      • 示例库
      • 教程
      • API引用
      • 引用
      • 档案文件
  • Page
      • seaborn.cubehelix_palette

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系统生成一个顺序调色板。

这将生成亮度线性降低(或增加)的颜色贴图。这意味着,如果打印成黑白或由色盲人士查看,信息将被保留。”“cubehelix”也可以作为基于matplotlib的调色板使用,但此函数使用户可以更好地控制调色板的外观,并具有不同的默认设置。

除了使用此函数,还可以使用字符串速记生成seaborn中的cubehelix调色板;请参见下面的示例。

参数
n_colors利息

调色板中的颜色数。

start浮动,0<=开始<=3

螺旋开始处的色调。

rot浮动

在调色板范围内围绕色调控制盘旋转。

gamma浮点0<=gamma

Gamma factor强调较深(Gamma<1)或较浅(Gamma>1)的颜色。

hue浮动,0<=色调<=1

颜色的饱和度。

dark浮动0<=暗<=1

调色板中最暗颜色的强度。

light浮动0<=灯光<=1

调色板中最浅颜色的强度。

reverse布尔

如果为真,调色板将由暗变亮。

as_cmap布尔

如果为True,则返回 matplotlib.colors.Colormap .

返回
RGB元组或 matplotlib.colors.Colormap

参见

choose_cubehelix_palette

启动一个交互式小部件来选择cubehelix调色板参数。

dark_palette

创建具有暗低值的顺序调色板。

light_palette

创建具有亮低值的顺序调色板。

工具书类

Green,D.A.(2011年)。”一种显示天文强度图象的颜色方案。印度天文学会公报,第39卷,第289-295页。

实例

生成默认调色板:

>>> import seaborn as sns; sns.set_theme()
>>> sns.palplot(sns.cubehelix_palette())
../_images/seaborn-cubehelix_palette-1.png

从同一起始位置向后旋转:

>>> sns.palplot(sns.cubehelix_palette(rot=-.4))
../_images/seaborn-cubehelix_palette-2.png

使用不同的起点和较短的旋转:

>>> sns.palplot(sns.cubehelix_palette(start=2.8, rot=.1))
../_images/seaborn-cubehelix_palette-3.png

反转亮度渐变的方向:

>>> sns.palplot(sns.cubehelix_palette(reverse=True))
../_images/seaborn-cubehelix_palette-4.png

生成colormap对象:

>>> from numpy import arange
>>> x = arange(25).reshape(5, 5)
>>> cmap = sns.cubehelix_palette(as_cmap=True)
>>> ax = sns.heatmap(x, cmap=cmap)
../_images/seaborn-cubehelix_palette-5.png

使用全亮度范围:

>>> cmap = sns.cubehelix_palette(dark=0, light=1, as_cmap=True)
>>> ax = sns.heatmap(x, cmap=cmap)
../_images/seaborn-cubehelix_palette-6.png

通过 color_palette() 接口:

>>> sns.palplot(sns.color_palette("ch:2,r=.2,l=.6"))
../_images/seaborn-cubehelix_palette-7.png

Back to top

© Copyright 2012-2021, Michael Waskom. 构建基于 Sphinx 3.4.1.