You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Applications are open for the 2018 John Hunter Matplotlib Summer Fellowship. Apply now!
Version 2.2.2.post1695+gedd053d16
matplotlib
Fork me on GitHub

Table Of Contents

matplotlib.colors.ListedColormap

class matplotlib.colors.ListedColormap(colors, name='from_list', N=None)[source]

Colormap object generated from a list of colors.

This may be most useful when indexing directly into a colormap, but it can also be used to generate special colormaps for ordinary mapping.

Make a colormap from a list of colors.

colors
a list of matplotlib color specifications, or an equivalent Nx3 or Nx4 floating point array (N rgb or rgba values)
name
a string to identify the colormap
N

the number of entries in the map. The default is None, in which case there is one colormap entry for each element in the list of colors. If:

N < len(colors)

the list will be truncated at N. If:

N > len(colors)

the list will be extended by repetition.

reversed(name=None)[source]

Make a reversed instance of the Colormap.

Parameters:
name : str, optional

The name for the reversed colormap. If it's None the name will be the name of the parent colormap + "_r".

Returns:
ListedColormap

A reversed instance of the colormap.

Examples using matplotlib.colors.ListedColormap