MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / __init__

Method __init__

lib/matplotlib/colors.py:2621–2660  ·  view source on GitHub ↗

Normalize data with a set center. Useful when mapping data with an unequal rates of change around a conceptual center, e.g., data that range from -2 to 4, with 0 as the midpoint. Parameters ---------- vcenter : float The data val

(self, vcenter, vmin=None, vmax=None)

Source from the content-addressed store, hash-verified

2619
2620class TwoSlopeNorm(Normalize):
2621 def __init__(self, vcenter, vmin=None, vmax=None):
2622 """
2623 Normalize data with a set center.
2624
2625 Useful when mapping data with an unequal rates of change around a
2626 conceptual center, e.g., data that range from -2 to 4, with 0 as
2627 the midpoint.
2628
2629 Parameters
2630 ----------
2631 vcenter : float
2632 The data value that defines ``0.5`` in the normalization.
2633 vmin : float, optional
2634 The data value that defines ``0.0`` in the normalization.
2635 Defaults to the min value of the dataset.
2636 vmax : float, optional
2637 The data value that defines ``1.0`` in the normalization.
2638 Defaults to the max value of the dataset.
2639
2640 Examples
2641 --------
2642 This maps data value -4000 to 0., 0 to 0.5, and +10000 to 1.0; data
2643 between is linearly interpolated::
2644
2645 >>> import matplotlib.colors as mcolors
2646 >>> offset = mcolors.TwoSlopeNorm(vmin=-4000.,
2647 ... vcenter=0., vmax=10000)
2648 >>> data = [-4000., -2000., 0., 2500., 5000., 7500., 10000.]
2649 >>> offset(data)
2650 array([0., 0.25, 0.5, 0.625, 0.75, 0.875, 1.0])
2651 """
2652
2653 super().__init__(vmin=vmin, vmax=vmax)
2654 self._vcenter = vcenter
2655 if vcenter is not None and vmax is not None and vcenter >= vmax:
2656 raise ValueError('vmin, vcenter, and vmax must be in '
2657 'ascending order')
2658 if vcenter is not None and vmin is not None and vcenter <= vmin:
2659 raise ValueError('vmin, vcenter, and vmax must be in '
2660 'ascending order')
2661
2662 @property
2663 def vcenter(self):

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected