matplotlib.colors.BivarColormap#
- class matplotlib.colors.BivarColormap(N=256, M=256, shape='square', origin=(0, 0), name='bivariate colormap')[source]#
Bases:
object
Base class for all bivariate to RGBA mappings.
Designed as a drop-in replacement for Colormap when using a 2D lookup table. To be used with
ScalarMappable
.- Parameters:
- Nint, default: 256
The number of RGB quantization levels along the first axis.
- Mint, default: 256
The number of RGB quantization levels along the second axis.
- shape{'square', 'circle', 'ignore', 'circleignore'}
'square' each variate is clipped to [0,1] independently
'circle' the variates are clipped radially to the center of the colormap, and a circular mask is applied when the colormap is displayed
'ignore' the variates are not clipped, but instead assigned the 'outside' color
'circleignore' a circular mask is applied, but the data is not clipped and instead assigned the 'outside' color
- origin(float, float), default: (0,0)
The relative origin of the colormap. Typically (0, 0), for colormaps that are linear on both axis, and (.5, .5) for circular colormaps. Used when getting 1D colormaps from 2D colormaps.
- namestr, optional
The name of the colormap.
- __call__(X, alpha=None, bytes=False)[source]#
- Parameters:
- Xtuple (X0, X1), X0 and X1: float 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*100
percent along the Colormap.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, default: None
Alpha must be a scalar between 0 and 1, a sequence of such floats with shape matching X0, or None.
- bytesbool, default: False
If False (default), the returned RGBA values will be floats in the interval
[0, 1]
otherwise they will benumpy.uint8
s 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, )
.
- property lut#
For external access to the lut, i.e. for displaying the cmap. For circular colormaps this returns a lut with a circular mask.
Internal functions (such as to_rgb()) should use _lut which stores the lut without a circular mask A lut without the circular mask is needed in to_rgb() because the conversion from floats to ints results in some some pixel-requests just outside of the circular mask
- property origin#
- resampled(lutshape, transposed=False)[source]#
Return a new colormap with lutshape entries.
Note that this function does not move the origin.
- Parameters:
- lutshapetuple of ints or None
The tuple must be of length 2, and each entry is either an int or None.
If an int, the corresponding axis is resampled.
If negative the corresponding axis is resampled in reverse
If -1, the axis is inverted
If 1 or None, the corresponding axis is not resampled.
- transposedbool, default: False
if True, the axes are swapped after resampling
- Returns:
- BivarColormap
- property shape#
- with_extremes(*, bad=None, outside=None, shape=None, origin=None)[source]#
Return a copy of the
BivarColormap
with modified attributes.Note that the outside color is only relevant if
shape
= 'ignore' or 'circleignore'.- Parameters:
- badNone or color
If Matplotlib color, the bad value is set accordingly in the copy
- outsideNone or color
If Matplotlib color and shape is 'ignore' or 'circleignore', values outside the colormap are colored accordingly in the copy
- shape{'square', 'circle', 'ignore', 'circleignore'}
If 'square' each variate is clipped to [0,1] independently
If 'circle' the variates are clipped radially to the center of the colormap, and a circular mask is applied when the colormap is displayed
If 'ignore' the variates are not clipped, but instead assigned the outside color
If 'circleignore' a circular mask is applied, but the data is not clipped and instead assigned the outside color
- origin(float, float)
The relative origin of the colormap. Typically (0, 0), for colormaps that are linear on both axis, and (.5, .5) for circular colormaps. Used when getting 1D colormaps from 2D colormaps.
- Returns:
- BivarColormap
copy of self with attributes set