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 5b18170

Browse filesBrowse files
authored
Merge pull request #13176 from meeseeksmachine/auto-backport-of-pr-13047-on-v3.0.x
Backport PR #13047 on branch v3.0.x (Improve docs on contourf extend)
2 parents 6bf7a2b + 0724082 commit 5b18170
Copy full SHA for 5b18170

File tree

Expand file treeCollapse file tree

1 file changed

+36
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+36
-8
lines changed

‎lib/matplotlib/contour.py

Copy file name to clipboardExpand all lines: lib/matplotlib/contour.py
+36-8Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,14 +1775,42 @@ def _initialize_x_y(self, z):
17751775
are not given explicitly via *levels*.
17761776
Defaults to `~.ticker.MaxNLocator`.
17771777
1778-
extend : {'neither', 'both', 'min', 'max'}, optional
1779-
Unless this is 'neither', contour levels are automatically
1780-
added to one or both ends of the range so that all data
1781-
are included. These added ranges are then mapped to the
1782-
special colormap values which default to the ends of the
1783-
colormap range, but can be set via
1784-
:meth:`matplotlib.colors.Colormap.set_under` and
1785-
:meth:`matplotlib.colors.Colormap.set_over` methods.
1778+
extend : {'neither', 'both', 'min', 'max'}, optional, default: \
1779+
'neither'
1780+
Determines the ``contourf``-coloring of values that are outside the
1781+
*levels* range.
1782+
1783+
If 'neither', values outside the *levels* range are not colored.
1784+
If 'min', 'max' or 'both', color the values below, above or below
1785+
and above the *levels* range.
1786+
1787+
Values below ``min(levels)`` and above ``max(levels)`` are mapped
1788+
to the under/over values of the `.Colormap`. Note, that most
1789+
colormaps do not have dedicated colors for these by default, so
1790+
that the over and under values are the edge values of the colormap.
1791+
You may want to set these values explicitly using
1792+
`.Colormap.set_under` and `.Colormap.set_over`.
1793+
1794+
.. note::
1795+
1796+
An exising `.QuadContourSet` does not get notified if
1797+
properties of its colormap are changed. Therefore, an explicit
1798+
call `.QuadContourSet.changed()` is needed after modifying the
1799+
colormap. The explicit call can be left out, if a colorbar is
1800+
assigned to the `.QuadContourSet` because it interally calls
1801+
`.QuadContourSet.changed()`.
1802+
1803+
Example::
1804+
1805+
x = np.arange(1, 10)
1806+
y = x.reshape(-1, 1)
1807+
h = x * y
1808+
1809+
cs = plt.contourf(h, levels=[10, 30, 50],
1810+
colors=['#808080', '#A0A0A0', '#C0C0C0'], extend='both')
1811+
cs.cmap.set_over('red')
1812+
cs.cmap.set_under('blue')
1813+
cs.changed()
17861814
17871815
xunits, yunits : registered units, optional
17881816
Override axis units by specifying an instance of a

0 commit comments

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