matplotlib.colors.CenteredNorm#
- classmatplotlib.colors.CenteredNorm(vcenter=0,halfrange=None,clip=False)[source]#
Bases:
NormalizeNormalize symmetrical data around a center (0 by default).
Unlike
TwoSlopeNorm,CenteredNormapplies 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 defines
0.5in the normalization.- halfrangefloat, optional
The range of data values that defines a range of
0.5in thenormalization, so thatvcenter -halfrange is0.0andvcenter +halfrange is1.0in 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. ])
- propertyhalfrange#
- propertyvcenter#
- propertyvmax#
Upper limit of the input data interval; maps to 1.
- propertyvmin#
Lower limit of the input data interval; maps to 0.