This module provides a large set of colormaps, functions for registering new colormaps and for getting a colormap by name, and a mixin class for adding color mapping functionality.
This is a mixin class to support scalar -> RGBA mapping. Handles normalization and colormapping
norm is an instance of colors.Normalize or one of its subclasses, used to map luminance to 0-1. cmap is a cm colormap instance, for example cm.jet
Add an entry to a dictionary of boolean flags that are set to True when the mappable is changed.
Autoscale the scalar limits on the norm instance using the current array
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
Call this whenever the mappable is changed to notify all the callbackSM listeners to the ‘changed’ signal
If mappable has changed since the last check, return True; else return False
Return the array
return the min, max of the color limits for image scaling
return the colormap
Set the image array from numpy array A
set the norm limits for image scaling; if vmin is a length2 sequence, interpret it as (vmin, vmax) which is used to support setp
ACCEPTS: a length 2 sequence of floats
set the colormap for luminance data
ACCEPTS: a colormap or registered colormap name
set the colorbar image and axes associated with mappable
set the normalization instance
Return a normalized rgba array corresponding to x.
In the normal case, x is a 1-D or 2-D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable.
There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4.
In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range.
Note: this method assumes the input is well-behaved; it does not check for anomalies such as x being a masked rgba array, or being an integer type other than uint8, or being a floating point rgba array with values outside the 0-1 range.
Get a colormap instance, defaulting to rc values if name is None.
Colormaps added with register_cmap() take precedence over builtin colormaps.
If name is a colors.Colormap instance, it will be returned.
If lut is not None it must be an integer giving the number of entries desired in the lookup table, and name must be a standard mpl colormap name with a corresponding data dictionary in datad.
Add a colormap to the set recognized by get_cmap().
It can be used in two ways:
register_cmap(name='swirly', cmap=swirly_cmap) register_cmap(name='choppy', data=choppydata, lut=128)
In the first case, cmap must be a colors.Colormap instance. The name is optional; if absent, the name will be the name attribute of the cmap.
In the second case, the three arguments are passed to the colors.LinearSegmentedColormap initializer, and the resulting colormap is registered.
Can only handle specification data in dictionary format.