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 70ec5ad

Browse filesBrowse files
authored
Merge pull request #26481 from timhoffm/doc-clip
Clarify behavior of norm clipping
2 parents 4a80a41 + 7a190e1 commit 70ec5ad
Copy full SHA for 70ec5ad

File tree

Expand file treeCollapse file tree

1 file changed

+46
-20
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+46
-20
lines changed

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+46-20Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,13 +1228,18 @@ def __init__(self, vmin=None, vmax=None, clip=False):
12281228
processed; i.e., ``__call__(A)`` calls ``autoscale_None(A)``.
12291229
12301230
clip : bool, default: False
1231-
If ``True`` values falling outside the range ``[vmin, vmax]``,
1232-
are mapped to 0 or 1, whichever is closer, and masked values are
1233-
set to 1. If ``False`` masked values remain masked.
1231+
Determines the behavior for mapping values outside the range
1232+
``[vmin, vmax]``.
1233+
1234+
If clipping is off, values outside the range ``[vmin, vmax]`` are also
1235+
transformed linearly, resulting in values outside ``[0, 1]``. For a
1236+
standard use with colormaps, this behavior is desired because colormaps
1237+
mark these outside values with specific colors for *over* or *under*.
12341238
1235-
Clipping silently defeats the purpose of setting the over and
1236-
under colors in a colormap, so it is likely to lead to
1237-
surprises; therefore the default is ``clip=False``.
1239+
If ``True`` values falling outside the range ``[vmin, vmax]``,
1240+
are mapped to 0 or 1, whichever is closer. This makes these values
1241+
indistinguishable from regular boundary values and can lead to
1242+
misinterpretation of the data.
12381243
12391244
Notes
12401245
-----
@@ -1330,6 +1335,8 @@ def __call__(self, value, clip=None):
13301335
value
13311336
Data to normalize.
13321337
clip : bool, optional
1338+
See the description of the parameter *clip* in `.Normalize`.
1339+
13331340
If ``None``, defaults to ``self.clip`` (which defaults to
13341341
``False``).
13351342
@@ -1524,9 +1531,18 @@ def __init__(self, vcenter=0, halfrange=None, clip=False):
15241531
Defaults to the largest absolute difference to *vcenter* for
15251532
the values in the dataset.
15261533
clip : bool, default: False
1534+
Determines the behavior for mapping values outside the range
1535+
``[vmin, vmax]``.
1536+
1537+
If clipping is off, values outside the range ``[vmin, vmax]`` are also
1538+
transformed, resulting in values outside ``[0, 1]``. For a
1539+
standard use with colormaps, this behavior is desired because colormaps
1540+
mark these outside values with specific colors for *over* or *under*.
1541+
15271542
If ``True`` values falling outside the range ``[vmin, vmax]``,
1528-
are mapped to 0 or 1, whichever is closer, and masked values are
1529-
set to 1. If ``False`` masked values remain masked.
1543+
are mapped to 0 or 1, whichever is closer. This makes these values
1544+
indistinguishable from regular boundary values and can lead to
1545+
misinterpretation of the data.
15301546
15311547
Examples
15321548
--------
@@ -1799,13 +1815,18 @@ def forward(values: array-like) -> array-like
17991815
processed; i.e., ``__call__(A)`` calls ``autoscale_None(A)``.
18001816
18011817
clip : bool, default: False
1802-
If ``True`` values falling outside the range ``[vmin, vmax]``,
1803-
are mapped to 0 or 1, whichever is closer, and masked values are
1804-
set to 1. If ``False`` masked values remain masked.
1818+
Determines the behavior for mapping values outside the range
1819+
``[vmin, vmax]``.
1820+
1821+
If clipping is off, values outside the range ``[vmin, vmax]`` are also
1822+
transformed by the function, resulting in values outside ``[0, 1]``. For a
1823+
standard use with colormaps, this behavior is desired because colormaps
1824+
mark these outside values with specific colors for *over* or *under*.
18051825
1806-
Clipping silently defeats the purpose of setting the over and
1807-
under colors in a colormap, so it is likely to lead to
1808-
surprises; therefore the default is ``clip=False``.
1826+
If ``True`` values falling outside the range ``[vmin, vmax]``,
1827+
are mapped to 0 or 1, whichever is closer. This makes these values
1828+
indistinguishable from regular boundary values and can lead to
1829+
misinterpretation of the data.
18091830
"""
18101831

18111832

@@ -1899,13 +1920,18 @@ class PowerNorm(Normalize):
18991920
minimum and maximum value, respectively, of the first input
19001921
processed; i.e., ``__call__(A)`` calls ``autoscale_None(A)``.
19011922
clip : bool, default: False
1902-
If ``True`` values falling outside the range ``[vmin, vmax]``,
1903-
are mapped to 0 or 1, whichever is closer, and masked values
1904-
remain masked.
1923+
Determines the behavior for mapping values outside the range
1924+
``[vmin, vmax]``.
1925+
1926+
If clipping is off, values outside the range ``[vmin, vmax]`` are also
1927+
transformed by the power function, resulting in values outside ``[0, 1]``. For
1928+
a standard use with colormaps, this behavior is desired because colormaps
1929+
mark these outside values with specific colors for *over* or *under*.
19051930
1906-
Clipping silently defeats the purpose of setting the over and under
1907-
colors, so it is likely to lead to surprises; therefore the default
1908-
is ``clip=False``.
1931+
If ``True`` values falling outside the range ``[vmin, vmax]``,
1932+
are mapped to 0 or 1, whichever is closer. This makes these values
1933+
indistinguishable from regular boundary values and can lead to
1934+
misinterpretation of the data.
19091935
19101936
Notes
19111937
-----

0 commit comments

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