matplotlib.colors.Colormap#
- class matplotlib.colors.Colormap(name, N=256)[source]#
Bases:
objectBaseclass 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 seematplotlib.colors.Normalize. Subclasses ofmatplotlib.cm.ScalarMappablemake heavy use of thisdata -> normalize -> map-to-colorprocessing chain.- Parameters:
- namestr
The name of the colormap.
- Nint
The number of RGB quantization levels.
- __call__(X, alpha=None, bytes=False)[source]#
- Parameters:
- Xfloat or int or array-like
The data value(s) to convert to RGBA. For floats, X should be in the interval
[0.0, 1.0]to return the RGBA valuesX*100percent along the Colormap line. For integers, X should be in the interval[0, Colormap.N)to return RGBA values indexed from the Colormap with indexX.- alphafloat or array-like or None
Alpha must be a scalar between 0 and 1, a sequence of such floats with shape matching X, or None.
- bytesbool, default: False
If False (default), the returned RGBA values will be floats in the interval
[0, 1]otherwise they will benumpy.uint8s in the interval[0, 255].
- Returns:
- Tuple of RGBA values if X is scalar, otherwise an array of
- RGBA values with a shape of
X.shape + (4, ).
- colorbar_extend#
When this colormap exists on a scalar mappable and colorbar_extend is not False, colorbar creation will pick up
colorbar_extendas the default value for theextendkeyword in thematplotlib.colorbar.Colorbarconstructor.
- reversed(name=None)[source]#
Return a reversed instance of the Colormap.
Note
This function is not implemented for the base class.
- Parameters:
- namestr, optional
The name for the reversed colormap. If None, the name is set to
self.name + "_r".