Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a4aafd1

Browse files
committed
Documentation tweaks from review.
1 parent ffce3b9 commit a4aafd1

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

doc/users/next_whats_new/2020-05-28-extend_kwarg_to_BoundaryNorm.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
New "extend" keyword to colors.BoundaryNorm
22
-------------------------------------------
33

4-
`~.colors.BoundaryNorm` now has an ``extend`` kwarg,
5-
analogous to ``extend`` in ~.axes._axes.Axes.contourf`. When set to
6-
'both', 'min', or 'max', it interpolates such that the corresponding
7-
out-of-range values are mapped to colors distinct from their in-range
8-
neighbors. The colorbar inherits the ``extend`` argument from the
9-
norm, so with ``extend='both'``, for example, the colorbar will have
10-
triangular extensions for out-of-range values with colors that differ
11-
from adjacent colors.
4+
`~.colors.BoundaryNorm` now has an ``extend`` keyword argument, analogous to
5+
``extend`` in ~.axes._axes.Axes.contourf`. When set to 'both', 'min', or 'max',
6+
it maps the corresponding out-of-range values to `~.colors.Colormap`
7+
lookup-table indices near the appropriate ends of their range so that the
8+
colors for out-of range values are adjacent to, but distinct from, their
9+
in-range neighbors. The colorbar inherits the ``extend`` argument from the
10+
norm, so with ``extend='both'``, for example, the colorbar will have triangular
11+
extensions for out-of-range values with colors that differ from adjacent
12+
colors.
1213

1314
.. plot::
1415

lib/matplotlib/colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ def __init__(self, boundaries, ncolors, clip=False, extend='neither'):
14341434
pair of boundaries is mapped will be distinct from the first
14351435
color in the colormap, and by default a
14361436
`~matplotlib.colorbar.Colorbar` will be drawn with
1437-
the triangle extension on the left side.
1437+
the triangle extension on the left or lower end.
14381438
14391439
Notes
14401440
-----

tutorials/colors/colorbar_only.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
###############################################################################
4343
# Extended colorbar with continuous colorscale
4444
# --------------------------------------------
45-
45+
#
4646
# The second example shows how to make a discrete colorbar based on a
47-
# continuous cmap. With the "extend" kwarg the appropriate colors are chosen to
48-
# fill the colorspace, including the extensions:
47+
# continuous cmap. With the "extend" keyword argument the appropriate colors
48+
# are chosen to fill the colorspace, including the extensions:
4949
fig, ax = plt.subplots(figsize=(6, 1))
5050
fig.subplots_adjust(bottom=0.5)
5151

@@ -62,7 +62,7 @@
6262
# Discrete intervals colorbar
6363
# ---------------------------
6464
#
65-
# The second example illustrates the use of a
65+
# The third example illustrates the use of a
6666
# :class:`~matplotlib.colors.ListedColormap` which generates a colormap from a
6767
# set of listed colors, `.colors.BoundaryNorm` which generates a colormap
6868
# index based on discrete intervals and extended ends to show the "over" and
@@ -74,11 +74,15 @@
7474
# bounds array must be one greater than the length of the color list. The
7575
# bounds must be monotonically increasing.
7676
#
77-
# This time we pass some more arguments in addition to previous arguments to
78-
# `~.Figure.colorbar`. For the out-of-range values to
79-
# display on the colorbar, we have to use the *extend* keyword argument. To use
80-
# *extend*, you must specify two extra boundaries. Finally spacing argument
81-
# ensures that intervals are shown on colorbar proportionally.
77+
# This time we pass additional arguments to
78+
# `~.Figure.colorbar`. For the out-of-range values to display on the colorbar
79+
# without using the *extend* keyword with
80+
# `.colors.BoundaryNorm`, we have to use the *extend* keyword argument directly
81+
# in the colorbar call, and supply an additional boundary on each end of the
82+
# range. Here we also
83+
# use the spacing argument to make
84+
# the length of each colorbar segment proportional to its corresponding
85+
# interval.
8286

8387
fig, ax = plt.subplots(figsize=(6, 1))
8488
fig.subplots_adjust(bottom=0.5)
@@ -92,7 +96,7 @@
9296
fig.colorbar(
9397
mpl.cm.ScalarMappable(cmap=cmap, norm=norm),
9498
cax=ax,
95-
boundaries=[0] + bounds + [13],
99+
boundaries=[0] + bounds + [13], # Adding values for extensions.
96100
extend='both',
97101
ticks=bounds,
98102
spacing='proportional',
@@ -104,7 +108,7 @@
104108
# Colorbar with custom extension lengths
105109
# --------------------------------------
106110
#
107-
# Here we illustrate the use of custom length colorbar extensions, used on a
111+
# Here we illustrate the use of custom length colorbar extensions, on a
108112
# colorbar with discrete intervals. To make the length of each extension the
109113
# same as the length of the interior colors, use ``extendfrac='auto'``.
110114

tutorials/colors/colormapnorms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
# which data is to be mapped. The colors are then linearly distributed between
148148
# these "bounds". It can also take an *extend* argument to add upper and/or
149149
# lower out-of-bounds values to the range over which the colors are
150-
# distributed For instance:
150+
# distributed. For instance:
151151
#
152152
# .. ipython::
153153
#

0 commit comments

Comments
 (0)