0.11.2
  • Gallery
  • Tutorial
  • API
  • Site
      • Introduction
      • Release notes
      • Installing
      • Example gallery
      • Tutorial
      • API reference
      • Citing
      • Archive
  • Page
      • seaborn.diverging_palette

seaborn.diverging_palette¶

seaborn.diverging_palette(h_neg, h_pos, s=75, l=50, sep=1, n=6, center='light', as_cmap=False)¶

Make a diverging palette between two HUSL colors.

If you are using the IPython notebook, you can also choose this palette interactively with the choose_diverging_palette() function.

Parameters
h_neg, h_posfloat in [0, 359]

Anchor hues for negative and positive extents of the map.

sfloat in [0, 100], optional

Anchor saturation for both extents of the map.

lfloat in [0, 100], optional

Anchor lightness for both extents of the map.

sepint, optional

Size of the intermediate region.

nint, optional

Number of colors in the palette (if not returning a cmap)

center{“light”, “dark”}, optional

Whether the center of the palette is light or dark

as_cmapbool, optional

If True, return a matplotlib.colors.Colormap.

Returns
list of RGB tuples or matplotlib.colors.Colormap

See also

dark_palette

Create a sequential palette with dark values.

light_palette

Create a sequential palette with light values.

Examples

Generate a blue-white-red palette:

>>> import seaborn as sns; sns.set_theme()
>>> sns.palplot(sns.diverging_palette(240, 10, n=9))
../_images/seaborn-diverging_palette-1.png

Generate a brighter green-white-purple palette:

>>> sns.palplot(sns.diverging_palette(150, 275, s=80, l=55, n=9))
../_images/seaborn-diverging_palette-2.png

Generate a blue-black-red palette:

>>> sns.palplot(sns.diverging_palette(250, 15, s=75, l=40,
...                                   n=9, center="dark"))
../_images/seaborn-diverging_palette-3.png

Generate a colormap object:

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

Back to top

© Copyright 2012-2021, Michael Waskom. Created using Sphinx 3.3.1.