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

Appearance settings

Commit 3bfa438

Browse filesBrowse files
authored
Merge pull request #8007 from dstansby/boundarynorm-docstring
[MRG+1] Clean up BoundaryNorm docstring
2 parents 1f173dd + 9dd7110 commit 3bfa438
Copy full SHA for 3bfa438

File tree

Expand file treeCollapse file tree

1 file changed

+28
-17
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-17
lines changed

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+28-17Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,25 +1247,29 @@ class BoundaryNorm(Normalize):
12471247
"""
12481248
def __init__(self, boundaries, ncolors, clip=False):
12491249
"""
1250-
*boundaries*
1251-
a monotonically increasing sequence
1252-
*ncolors*
1253-
number of colors in the colormap to be used
1254-
1255-
If::
1256-
1257-
b[i] <= v < b[i+1]
1250+
Parameters
1251+
----------
1252+
boundaries : array-like
1253+
Monotonically increasing sequence of boundaries
1254+
ncolors : int
1255+
Number of colors in the colormap to be used
1256+
clip : bool, optional
1257+
If clip is ``True``, out of range values are mapped to 0 if they
1258+
are below ``boundaries[0]`` or mapped to ncolors - 1 if they are
1259+
above ``boundaries[-1]``.
1260+
1261+
If clip is ``False``, out of range values are mapped to -1 if
1262+
they are below ``boundaries[0]`` or mapped to ncolors if they are
1263+
above ``boundaries[-1]``. These are then converted to valid indices
1264+
by :meth:`Colormap.__call__`.
12581265
1259-
then v is mapped to color j;
1260-
as i varies from 0 to len(boundaries)-2,
1261-
j goes from 0 to ncolors-1.
1266+
Notes
1267+
-----
1268+
*boundaries* defines the edges of bins, and data falling within a bin
1269+
is mapped to the color with the same index.
12621270
1263-
Out-of-range values are mapped
1264-
to -1 if low and ncolors if high; these are converted
1265-
to valid indices by
1266-
:meth:`Colormap.__call__` .
1267-
If clip == True, out-of-range values
1268-
are mapped to 0 if low and ncolors-1 if high.
1271+
If the number of bins doesn't equal *ncolors*, the color is chosen
1272+
by linear interpolation of the bin number onto color numbers.
12691273
"""
12701274
self.clip = clip
12711275
self.vmin = boundaries[0]
@@ -1304,6 +1308,13 @@ def __call__(self, value, clip=None):
13041308
return ret
13051309

13061310
def inverse(self, value):
1311+
"""
1312+
Raises
1313+
------
1314+
ValueError
1315+
BoundaryNorm is not invertible, so calling this method will always
1316+
raise an error
1317+
"""
13071318
return ValueError("BoundaryNorm is not invertible")
13081319

13091320

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.