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)

Make a sequential palette from the cubehelix system.

This produces a colormap with linearly-decreasing (or increasing) brightness. That means that information will be preserved if printed to black and white or viewed by someone who is colorblind. “cubehelix” is also available as a matplotlib-based palette, but this function gives the user more control over the look of the palette and has a different set of defaults.

In addition to using this function, it is also possible to generate a cubehelix palette generally in seaborn using a string-shorthand; see the example below.

Parameters
n_colorsint

Number of colors in the palette.

startfloat, 0 <= start <= 3

The hue at the start of the helix.

rotfloat

Rotations around the hue wheel over the range of the palette.

gammafloat 0 <= gamma

Gamma factor to emphasize darker (gamma < 1) or lighter (gamma > 1) colors.

huefloat, 0 <= hue <= 1

Saturation of the colors.

darkfloat 0 <= dark <= 1

Intensity of the darkest color in the palette.

lightfloat 0 <= light <= 1

Intensity of the lightest color in the palette.

reversebool

If True, the palette will go from dark to light.

as_cmapbool

If True, return a matplotlib colormap instead of a list of colors.

Returns
palette or cmapseaborn color palette or matplotlib colormap

List-like object of colors as RGB tuples, or colormap object that can map continuous values to colors, depending on the value of the as_cmap parameter.

See also

choose_cubehelix_palette

Launch an interactive widget to select cubehelix palette parameters.

dark_palette

Create a sequential palette with dark low values.

light_palette

Create a sequential palette with bright low values.

References

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.

Examples

Generate the default palette:

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

Rotate backwards from the same starting location:

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

Use a different starting point and shorter rotation:

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

Reverse the direction of the lightness ramp:

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

Generate a colormap object:

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

Use the full lightness range:

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

Use through the color_palette() interface:

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