matplotlib.colors.BivarColormap#

classmatplotlib.colors.BivarColormap(N=256,M=256,shape='square',origin=(0,0),name='bivariatecolormap')[source]#

Bases:object

Base class for all bivariate to RGBA mappings.

Designed as a drop-in replacement for Colormap when using a 2Dlookup table. To be used withScalarMappable.

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*100 percent 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 ofX.shape+(4,).
copy()[source]#

Return a copy of the colormap.

get_bad()[source]#

Get the color for masked values.

get_outside()[source]#

Get the color for out-of-range values.

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
reversed(axis_0=True,axis_1=True)[source]#

Reverses both or one of the axis.

propertyshape#
transposed()[source]#

Transposes the colormap by swapping the order of the axis

with_extremes(*,bad=None,outside=None,shape=None,origin=None)[source]#

Return a copy of theBivarColormap with modified attributes.

Note that theoutside color is only relevant ifshape = '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