You are reading an old version of the documentation (v3.1.1). For the latest version see
Version 3.1.2
Fork me on GitHub

Table of Contents


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

Bases: matplotlib.colors.Colormap

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.

colors : list, array

List of Matplotlib color specifications, or an equivalent Nx3 or Nx4 floating point array (N rgb or rgba values).

name : str, optional

String to identify the colormap.

N : int, optional

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(self, name=None)[source]

Make a reversed instance of the Colormap.

name : str, optional

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


A reversed instance of the colormap.