seaborn.cubehelix_palette

    用 cubehelix 系统制作顺序调色板。

    生成亮度呈线性减小(或增大)的 colormap。这意味着 colormap在转换为黑白模式时(用于打印)的信息将得到保留,且对色盲友好。“cubehelix” 也可以作为基于 matplotlib 的调色板使用,但此函数使用户可以更好地控制调色板的外观,并且具有一组不同的默认值。

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

    参数::int

    调色板中的颜色数。

    start:float, 0 <= start <= 3

    第一个色调。

    rot:float

    gamma:float 0 <= gamma

    Gamma 系数用以强调较深 (Gamma < 1) 或较浅 (Gamma > 1) 的颜色。

    hue:float, 0 <= hue <= 1

    颜色的饱和度。

    :float 0 <= light <= 1

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

    reverse:bool

    如果为 True 值,则调色板将从暗到亮。

    as_cmap:bool

    返回值:palette or cmap:seaborn 调色板或者 matplotlib colormap

    类似列表的颜色对象的 RGB 元组,或者可以将连续值映射到颜色的 colormap 对象,具体取决于 as_cmap 参数的值。

    另外

    启动交互式小部件以调整 cubehelix 调色板参数。创建具有暗低值的连续调色板。创建具有亮低值的连续调色板。

    参考

    Green, D. A. (2011). “一种用于显示天文强度图像的配色方案”. Bulletin of the Astromical Society of India, Vol. 39, p. 289-295.

    生成默认调色板:

    1. >>> import seaborn as sns; sns.set()

    从相同的起始位置向后旋转:

    http://seaborn.pydata.org/_images/seaborn-cubehelix_palette-2.png

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

      反转亮度渐变方向:

      http://seaborn.pydata.org/_images/seaborn-cubehelix_palette-4.png

      生成一个 colormap 对象:

      1. >>> from numpy import arange
      2. >>> x = arange(25).reshape(5, 5)
      3. >>> ax = sns.heatmap(x, cmap=cmap)

      使用完整的亮度范围:

      http://seaborn.pydata.org/_images/seaborn-cubehelix_palette-6.png

      使用 函数接口:

      1. >>> sns.palplot(sns.color_palette("ch:2,r=.2,l=.6"))