matplotlib.colors.CenteredNorm#

classmatplotlib.colors.CenteredNorm(vcenter=0,halfrange=None,clip=False)[source]#

Bases:Normalize

Normalize symmetrical data around a center (0 by default).

UnlikeTwoSlopeNorm,CenteredNorm applies an equal rate of changearound the center.

Useful when mapping symmetrical data around a conceptual centere.g., data that range from -2 to 4, with 0 as the midpoint, andwith equal rates of change around that midpoint.

Parameters:
vcenterfloat, default: 0

The data value that defines0.5 in the normalization.

halfrangefloat, optional

The range of data values that defines a range of0.5 in thenormalization, so thatvcenter -halfrange is0.0 andvcenter +halfrange is1.0 in the normalization.Defaults to the largest absolute difference tovcenter forthe values in the dataset.

clipbool, default: False

Determines the behavior for mapping values outside the range[vmin,vmax].

If clipping is off, values outside the range[vmin,vmax] arealso transformed, resulting in values outside[0,1]. Thisbehavior is usually desirable, as colormaps can mark theseunderandover values with specific colors.

If clipping is on, values belowvmin are mapped to 0 and valuesabovevmax are mapped to 1. Such values become indistinguishablefrom regular boundary values, which may cause misinterpretation ofthe data.

Examples

This maps data values -2 to 0.25, 0 to 0.5, and 4 to 1.0(assuming equal rates of change above and below 0.0):

>>>importmatplotlib.colorsasmcolors>>>norm=mcolors.CenteredNorm(halfrange=4.0)>>>data=[-2.,0.,4.]>>>norm(data)array([0.25, 0.5 , 1.  ])
autoscale(A)[source]#

Sethalfrange tomax(abs(A-vcenter)), then setvmin andvmax.

autoscale_None(A)[source]#

Setvmin andvmax.

propertyhalfrange#
propertyvcenter#
propertyvmax#

Upper limit of the input data interval; maps to 1.

propertyvmin#

Lower limit of the input data interval; maps to 0.

Examples usingmatplotlib.colors.CenteredNorm#

Colormap normalization

Colormap normalization