Movatterモバイル変換


[0]ホーム

URL:


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

Commit8ebdfb1

Browse files
committed
Improve docs on contourf extend
1 parent3826ee5 commit8ebdfb1

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

‎lib/matplotlib/contour.py‎

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp