@@ -1766,14 +1766,42 @@ def _initialize_x_y(self, z):
1766
1766
are not given explicitly via *levels*.
1767
1767
Defaults to `~.ticker.MaxNLocator`.
1768
1768
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()
1777
1805
1778
1806
xunits, yunits : registered units, optional
1779
1807
Override axis units by specifying an instance of a
0 commit comments