DiscreteNorm¶
- class DiscreteNorm(levels, norm=None, unique=None, step=None, clip=False)[source]¶
Bases:
matplotlib.colors.BoundaryNorm
Meta-normalizer that discretizes the possible color values returned by arbitrary continuous normalizers given a sequence of level boundaries.
- Parameters
levels (sequence of
float
) – The level boundaries. Must be monotonically increasing or decreasing.norm (
Normalize
, optional) – The normalizer used to transformlevels
and data values passed to__call__
before discretization. Thevmin
andvmax
of the normalizer are set to the minimum and maximum values inlevels
.unique (
{'neither', 'both', 'min', 'max'}
, optional) – Which out-of-bounds regions should be assigned unique colormap colors. Possible values are equivalent to theextend
values. The normalizer needs this information so it can ensure the colorbar always spans the full range of colormap colors. Internally, proplot sets this automatically depending on whether the colormap is cyclic and whether “extreme” colors were designated separately usingset_under
and/orset_over
.step (
float
, optional) – The intensity of the transition to out-of-bounds colors as a fraction of the adjacent step between in-bounds colors. Internally, proplot sets this to0.5
for cyclic colormaps and1
for all other colormaps.clip (
bool
, optional) – Whether to clip values falling outside of the level bins. This only has an effect on lower colors when unique is'min'
or'both'
, and on upper colors when unique is'max'
or'both'
.
Note
This normalizer also makes sure that levels always span the full range of colors in the colormap, whether
extend
is set to'min'
,'max'
,'neither'
, or'both'
. By default, whenextend
is not'both'
, matplotlib cuts off the most intense colors (reserved for “out of bounds” data), even though they are not being used. Note that this means using a diverging colormap withextend='max'
orextend='min'
will shift the central color by default. But that is very strange usage anyway… so please just don’t do that :)See also
Attributes Summary
Whether the normalizer levels are descending.
Methods Summary
__call__
(value[, clip])Normalize data values to 0-1.
inverse
(value)Raise an error.