seaborn.mpl_palette#
- seaborn.mpl_palette(name, n_colors=6, as_cmap=False)#
Return a palette or colormap from the matplotlib registry.
For continuous palettes, evenly-spaced discrete samples are chosen while excluding the minimum and maximum value in the colormap to provide better contrast at the extremes.
For qualitative palettes (e.g. those from colorbrewer), exact values are indexed (rather than interpolated), but fewer than
n_colors
can be returned if the palette does not define that many.- Parameters:
- namestring
Name of the palette. This should be a named matplotlib colormap.
- n_colorsint
Number of discrete colors in the palette.
- Returns:
- list of RGB tuples or
matplotlib.colors.ListedColormap
- list of RGB tuples or
Examples
Return discrete samples from a continuous matplotlib colormap:
sns.mpl_palette("viridis")
Return the continuous colormap instead; note how the extreme values are more intense:
sns.mpl_palette("viridis", as_cmap=True)
Return more colors:
sns.mpl_palette("viridis", 8)
Return values from a qualitative colormap:
sns.mpl_palette("Set2")
Notice how the palette will only contain distinct colors and can be shorter than requested:
sns.mpl_palette("Set2", 10)