get_cmap_safe

Contents

get_cmap_safe#

get_cmap_safe(cmap: ColormapOptions) colors.Colormap[source]#

Fetch a colormap by name from matplotlib, colorcet, cmocean, or cmcrameri.

See Named Colormaps for supported colormaps.

Parameters:
cmapstr | list[str] | matplotlib.colors.Colormap

Name of the colormap to fetch. If the input is a list of strings, the strings must be color names (from Named Colors), and it will create a ListedColormap with the input list.

Returns:
matplotlib.colors.Colormap

The requested colormap if available.

Raises:
ValueError

If the input colormap name is not valid.

TypeError

If the input is a list of items that are not strings.