Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 298e92f

Browse files
Merge pull request matplotlib#20898 from anntzer/bn
Reword BoundaryNorm docs.
2 parents 58cd97b + 3a0ca26 commit 298e92f

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

‎lib/matplotlib/colors.py‎

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,19 +1651,23 @@ class BoundaryNorm(Normalize):
16511651
16521652
Unlike `Normalize` or `LogNorm`, `BoundaryNorm` maps values to integers
16531653
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.
16581654
"""
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+
16591660
def __init__(self, boundaries, ncolors, clip=False, *, extend='neither'):
16601661
"""
16611662
Parameters
16621663
----------
16631664
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+
16651668
ncolors : int
16661669
Number of colors in the colormap to be used.
1670+
16671671
clip : bool, optional
16681672
If clip is ``True``, out of range values are mapped to 0 if they
16691673
are below ``boundaries[0]`` or mapped to ``ncolors - 1`` if they
@@ -1673,6 +1677,7 @@ def __init__(self, boundaries, ncolors, clip=False, *, extend='neither'):
16731677
they are below ``boundaries[0]`` or mapped to *ncolors* if they are
16741678
above ``boundaries[-1]``. These are then converted to valid indices
16751679
by `Colormap.__call__`.
1680+
16761681
extend : {'neither', 'both', 'min', 'max'}, default: 'neither'
16771682
Extend the number of bins to include one or both of the
16781683
regions beyond the boundaries. For example, if ``extend``
@@ -1682,18 +1687,12 @@ def __init__(self, boundaries, ncolors, clip=False, *, extend='neither'):
16821687
`~matplotlib.colorbar.Colorbar` will be drawn with
16831688
the triangle extension on the left or lower end.
16841689
1685-
Returns
1686-
-------
1687-
int16 scalar or array
1688-
16891690
Notes
16901691
-----
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.
16971696
"""
16981697
if clip and extend != 'neither':
16991698
raise ValueError("'clip=True' is not compatible with 'extend'")
@@ -1722,6 +1721,10 @@ def __init__(self, boundaries, ncolors, clip=False, *, extend='neither'):
17221721
"number of bins")
17231722

17241723
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+
"""
17251728
if clip is None:
17261729
clip = self.clip
17271730

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /