@@ -1651,19 +1651,23 @@ class BoundaryNorm(Normalize):
1651
1651
1652
1652
Unlike `Normalize` or `LogNorm`, `BoundaryNorm` maps values to integers
1653
1653
instead of to the interval 0-1.
1654
-
1655
- Mapping to the 0-1 interval could have been done via piece-wise linear
1656
- interpolation, but using integers seems simpler, and reduces the number of
1657
- conversions back and forth between integer and floating point.
1658
1654
"""
1655
+
1656
+ # Mapping to the 0-1 interval could have been done via piece-wise linear
1657
+ # interpolation, but using integers seems simpler, and reduces the number
1658
+ # of conversions back and forth between int and float.
1659
+
1659
1660
def __init__ (self , boundaries , ncolors , clip = False , * , extend = 'neither' ):
1660
1661
"""
1661
1662
Parameters
1662
1663
----------
1663
1664
boundaries : array-like
1664
- Monotonically increasing sequence of at least 2 boundaries.
1665
+ Monotonically increasing sequence of at least 2 bin edges: data
1666
+ falling in the n-th bin will be mapped to the n-th color.
1667
+
1665
1668
ncolors : int
1666
1669
Number of colors in the colormap to be used.
1670
+
1667
1671
clip : bool, optional
1668
1672
If clip is ``True``, out of range values are mapped to 0 if they
1669
1673
are below ``boundaries[0]`` or mapped to ``ncolors - 1`` if they
@@ -1673,6 +1677,7 @@ def __init__(self, boundaries, ncolors, clip=False, *, extend='neither'):
1673
1677
they are below ``boundaries[0]`` or mapped to *ncolors* if they are
1674
1678
above ``boundaries[-1]``. These are then converted to valid indices
1675
1679
by `Colormap.__call__`.
1680
+
1676
1681
extend : {'neither', 'both', 'min', 'max'}, default: 'neither'
1677
1682
Extend the number of bins to include one or both of the
1678
1683
regions beyond the boundaries. For example, if ``extend``
@@ -1682,18 +1687,12 @@ def __init__(self, boundaries, ncolors, clip=False, *, extend='neither'):
1682
1687
`~matplotlib.colorbar.Colorbar` will be drawn with
1683
1688
the triangle extension on the left or lower end.
1684
1689
1685
- Returns
1686
- -------
1687
- int16 scalar or array
1688
-
1689
1690
Notes
1690
1691
-----
1691
- *boundaries* defines the edges of bins, and data falling within a bin
1692
- is mapped to the color with the same index.
1693
-
1694
- If the number of bins, including any extensions, is less than
1695
- *ncolors*, the color index is chosen by linear interpolation, mapping
1696
- the ``[0, nbins - 1]`` range onto the ``[0, ncolors - 1]`` range.
1692
+ If there are fewer bins (including extensions) than colors, then the
1693
+ color index is chosen by linearly interpolating the ``[0, nbins - 1]``
1694
+ range onto the ``[0, ncolors - 1]`` range, effectively skipping some
1695
+ colors in the middle of the colormap.
1697
1696
"""
1698
1697
if clip and extend != 'neither' :
1699
1698
raise ValueError ("'clip=True' is not compatible with 'extend'" )
@@ -1722,6 +1721,10 @@ def __init__(self, boundaries, ncolors, clip=False, *, extend='neither'):
1722
1721
"number of bins" )
1723
1722
1724
1723
def __call__ (self , value , clip = None ):
1724
+ """
1725
+ This method behaves similarly to `.Normalize.__call__`, except that it
1726
+ returns integers or arrays of int16.
1727
+ """
1725
1728
if clip is None :
1726
1729
clip = self .clip
1727
1730
0 commit comments