DiscreteNorm
- class DiscreteNorm(levels, norm=None, unique=None, step=None, clip=False, ticks=None, labels=None)[source]
Bases:
BoundaryNormMeta-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. If the latter thendescendingis set toTrueand the colorbar axis drawn with this normalizer will be reversed.norm (
Normalize, optional) – The normalizer used to transformlevelsand data values passed to__call__before discretization. Thevminandvmaxof 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 theextendvalues. Internally, ultraplot sets this depending on the user-inputextend, whether the colormap is cyclic, and whetherset_underorset_overwere called for the colormap.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, ultraplot sets this to0.5for cyclic colormaps and1for all other colormaps. This only has an effect on lower colors whenuniqueis'min'or'both', and on upper colors whenuniqueis'max'or'both'.clip (
bool, optional) – Whether to clip values falling outside of the level bins. This only has an effect on lower colors whenuniqueis'min'or'both', and on upper colors whenuniqueis'max'or'both'.
- Other Parameters:
ticks (array-like, default:
levels) – Default tick values to use for colorbars drawn with this normalizer. This is set to the level centers whenvaluesis passed to a plotting command.labels (array-like, optional) – Default tick labels to use for colorbars drawn with this normalizer. This is set to values when drawing on-the-fly colorbars.
Note
This normalizer makes sure that levels always span the full range of colors in the colormap, whether
extendis set to'min','max','neither', or'both'. In matplotlib, whenextendis not'both', the most intense colors are cut off (reserved for “out of bounds” data), even though they are not being used.See also
ultraplot.constructor.Norm,ultraplot.colors.SegmentedNorm,ultraplot.ticker.DiscreteLocatorAttributes Summary
Boolean indicating whether the levels are descending.
Methods Summary
__call__(value[, clip])Normalize data values to 0-1.
inverse(value)Raise an error.
Attributes Documentation
- descending
Boolean indicating whether the levels are descending.
Methods Documentation
- __call__(value, clip=None)[source]
Normalize data values to 0-1.
- Parameters:
value (
numeric) – The data to be normalized.clip (
bool, default:self.clip) – Whether to clip values falling outside of the level bins.
- inverse(value)[source]
Raise an error.
- Raises:
ValueError – Inversion after discretization is impossible.