SegmentedNorm¶
- class SegmentedNorm(levels, vcenter=None, vmin=None, vmax=None, clip=None, fair=True)[source]¶
Bases:
NormalizeNormalizer that scales data linearly with respect to the interpolated index in an arbitrary monotonic level sequence.
- Parameters
levels (sequence of
float) – The level boundaries. Must be monotonically increasing or decreasing.vcenter (
float, default:None) – The central colormap value. Default is to omit this.vmin (
float, optional) – Ignored but included for consistency. Set tomin(levels).vmax (
float, optional) – Ignored but included for consistency. Set tomax(levels).clip (
bool, optional) – Whether to clip values falling outside ofvminandvmax.fair (
bool, optional) – Whether to use fair scaling. SeeDivergingNorm.
Note
The algorithm this normalizer uses to select normalized values in-between level list indices is adapted from the algorithm
LinearSegmentedColormapuses to select channel values in-between segment data points (hence the nameSegmentedNorm).Example
In the below example, unevenly spaced levels are passed to
contourf, resulting in the automatic application ofSegmentedNorm.>>> import proplot as pplt >>> import numpy as np >>> levels = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000] >>> data = 10 ** (3 * np.random.rand(10, 10)) >>> fig, ax = pplt.subplots() >>> ax.contourf(data, levels=levels)
Methods Summary
__call__(value[, clip])Normalize the data values to 0-1.
inverse(value)Inverse of
__call__.