seaborn.color_palette(palette=None, n_colors=None, desat=None)

Return a list of colors defining a color palette.

Available seaborn palette names:
deep, muted, bright, pastel, dark, colorblind
Other options:
hls, husl, any named matplotlib palette, list of colors

Calling this function with palette=None will return the current matplotlib color cycle.

Matplotlib palettes can be specified as reversed palettes by appending “_r” to the name or as dark palettes by appending “_d” to the name. (These options are mutually exclusive, but the resulting list of colors can also be reversed).

This function can also be used in a with statement to temporarily set the color cycle for a plot or set of plots.


palette: None, string, or sequence, optional

Name of palette or None to return current palette. If a sequence, input colors are used but possibly cycled and desaturated.

n_colors : int, optional

Number of colors in the palette. If None, the default will depend on how palette is specified. Named palettes default to 6 colors, but grabbing the current palette or passing in a list of colors will not change the number of colors unless this is specified. Asking for more colors than exist in the palette will cause it to cycle.

desat : float, optional

Proportion to desaturate each color by.


palette : list of RGB tuples.

Color palette. Behaves like a list, but can be used as a context manager and possesses an as_hex method to convert to hex color codes.

See also

Set the default color cycle for all plots.
Reassign color codes like "b", "g", etc. to colors from one of the seaborn palettes.


Show one of the “seaborn palettes”, which have the same basic order of hues as the default matplotlib color cycle but more attractive colors.

>>> import seaborn as sns; sns.set()
>>> sns.palplot(sns.color_palette("muted"))

Use discrete values from one of the built-in matplotlib colormaps.

>>> sns.palplot(sns.color_palette("RdBu", n_colors=7))

Make a “dark” matplotlib sequential palette variant. (This can be good when coloring multiple lines or points that correspond to an ordered variable, where you don’t want the lightest lines to be invisible).

>>> sns.palplot(sns.color_palette("Blues_d"))

Use a categorical matplotlib palette, add some desaturation. (This can be good when making plots with large patches, which look best with dimmer colors).

>>> sns.palplot(sns.color_palette("Set1", n_colors=8, desat=.5))

Use as a context manager:

>>> import numpy as np, matplotlib.pyplot as plt
>>> with sns.color_palette("husl", 8):
...    _ = plt.plot(np.c_[np.zeros(8), np.arange(8)].T)