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.post1336+gc1f0072e7
Fork me on GitHub

Table Of Contents


class matplotlib.colors.Colormap(name, N=256)[source]

Baseclass for all scalar to RGBA mappings.

Typically Colormap instances are used to convert data values (floats) from the interval [0, 1] to the RGBA color that the respective Colormap represents. For scaling of data into the [0, 1] interval see matplotlib.colors.Normalize. It is worth noting that subclasses make heavy use of this data->normalize->map-to-color processing chain.

name : str

The name of the colormap.

N : int

The number of rgb quantization levels.

colorbar_extend = None

When this colormap exists on a scalar mappable and colorbar_extend is not False, colorbar creation will pick up colorbar_extend as the default value for the extend keyword in the matplotlib.colorbar.Colorbar constructor.


Make a reversed instance of the Colormap.


Function not implemented for base class.

name : str, optional

The name for the reversed colormap. If it’s None the name will be the name of the parent colormap + “_r”.


See LinearSegmentedColormap.reversed() and ListedColormap.reversed()

set_bad(color='k', alpha=None)[source]

Set color to be used for masked values.

set_over(color='k', alpha=None)[source]

Set color to be used for high out-of-range values. Requires norm.clip = False

set_under(color='k', alpha=None)[source]

Set color to be used for low out-of-range values. Requires norm.clip = False

Examples using matplotlib.colors.Colormap