matplotlib.colors.BivarColormap#
- classmatplotlib.colors.BivarColormap(N=256,M=256,shape='square',origin=(0,0),name='bivariatecolormap')[source]#
Bases:
objectBase class for all bivariate to RGBA mappings.
Designed as a drop-in replacement for Colormap when using a 2Dlookup 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 centerof the colormap, and a circular mask is applied when the colormapis displayed
'ignore' the variates are not clipped, but instead assigned the'outside' color
'circleignore' a circular mask is applied, but the data is notclipped and instead assigned the 'outside' color
- origin(float, float), default: (0,0)
The relative origin of the colormap. Typically (0, 0), for colormapsthat 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]toreturn the RGBA valuesX*100percent along the Colormap.For integers,X should be in the interval
[0,Colormap.N)toreturn RGBA valuesindexed 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 suchfloats with shape matching X0, or None.
- bytesbool, default: False
If False (default), the returned RGBA values will be floats in theinterval
[0,1]otherwise they will benumpy.uint8s in theinterval[0,255].
- Returns:
- Tuple of RGBA values if X is scalar, otherwise an array of
- RGBA values with a shape of
X.shape+(4,).
- propertylut#
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 _lutwhich stores the lut without a circular maskA lut without the circular mask is needed in to_rgb() because theconversion from floats to ints results in some some pixel-requestsjust outside of the circular mask
- propertyorigin#
- resampled(lutshape,transposed=False)[source]#
Return a new colormap withlutshape 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
- propertyshape#
- with_extremes(*,bad=None,outside=None,shape=None,origin=None)[source]#
Return a copy of the
BivarColormapwith modified attributes.Note that theoutside color is only relevant if
shape= 'ignore'or 'circleignore'.- Parameters:
- badcolor, optional
If given, thebad value is set accordingly in the copy.
- outsidecolor, optional
If given and shape is 'ignore' or 'circleignore', valuesoutside 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 centerof the colormap, and a circular mask is applied when the colormapis displayed
If 'ignore' the variates are not clipped, but instead assigned theoutside color
If 'circleignore' a circular mask is applied, but the data is notclipped and instead assigned theoutside color
- origin(float, float)
The relative origin of the colormap. Typically (0, 0), for colormapsthat 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