matplotlib.colors.MultivarColormap#

class matplotlib.colors.MultivarColormap(colormaps, combination_mode, name='multivariate colormap')[source]#

Bases: object

Class for holding multiple Colormap for use in a ScalarMappable object

Parameters:
colormapslist or tuple of Colormap objects

The individual colormaps that are combined

combination_modestr, 'sRGB_add' or 'sRGB_sub'

Describe how colormaps are combined in sRGB space

  • If 'sRGB_add' -> Mixing produces brighter colors sRGB = sum(colors)

  • If 'sRGB_sub' -> Mixing produces darker colors sRGB = 1 - sum(1 - colors)

namestr, optional

The name of the colormap family.

__call__(X, alpha=None, bytes=False, clip=True)[source]#
Parameters:
Xtuple (X0, X1, ...) of length equal to the number of colormaps

X0, X1 ...: float or int, ndarray or scalar The data value(s) to convert to RGBA. For floats, Xi... should be in the interval [0.0, 1.0] to return the RGBA values X*100 percent along the Colormap line. For integers, Xi... should be in the interval [0, self[i].N) to return RGBA values indexed from colormap [i] with index Xi, where self[i] is colormap i.

alphafloat or array-like or None

Alpha must be a scalar between 0 and 1, a sequence of such floats with shape matching Xi, or None.

bytesbool, default: False

If False (default), the returned RGBA values will be floats in the interval [0, 1] otherwise they will be numpy.uint8s in the interval [0, 255].

clipbool, default: True

If True, clip output to 0 to 1

Returns:
Tuple of RGBA values if X[0] is scalar, otherwise an array of
RGBA values with a shape of X.shape + (4, ).
property combination_mode#
copy()[source]#

Return a copy of the multivarcolormap.

get_bad()[source]#

Get the color for masked values.

resampled(lutshape)[source]#

Return a new colormap with lutshape entries.

Parameters:
lutshapetuple of (int, None)

The tuple must have a length matching the number of variates. For each element in the tuple, if int, the corresponding colorbar is resampled, if None, the corresponding colorbar is not resampled.

Returns:
MultivarColormap
with_extremes(*, bad=None, under=None, over=None)[source]#

Return a copy of the MultivarColormap with modified out-of-range attributes.

The bad keyword modifies the copied MultivarColormap while under and over modifies the attributes of the copied component colormaps. Note that under and over colors are subject to the mixing rules determined by the combination_mode.

Parameters:
badcolor, default: None

If Matplotlib color, the bad value is set accordingly in the copy

undertuple of color, default: None

If tuple, the 'under' value of each component is set with the values from the tuple.

overtuple of color, default: None

If tuple, the 'over' value of each component is set with the values from the tuple.

Returns:
MultivarColormap

copy of self with attributes set