Skip to content

Commit 17cc7fc

Browse files
committed
Numpydocify _colormap_kw_doc and use it in Colorbar too.
1 parent 2b2ce9b commit 17cc7fc

File tree

1 file changed

+61
-80
lines changed

1 file changed

+61
-80
lines changed

lib/matplotlib/colorbar.py

Lines changed: 61 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -37,88 +37,85 @@
3737
and bottom are horizontal). If None, the location will come from the
3838
*orientation* if it is set (vertical colorbars on the right, horizontal
3939
ones at the bottom), or default to 'right' if *orientation* is unset.
40+
4041
orientation : None or {'vertical', 'horizontal'}
4142
The orientation of the colorbar. It is preferable to set the *location*
4243
of the colorbar, as that also determines the *orientation*; passing
4344
incompatible values for *location* and *orientation* raises an exception.
45+
4446
fraction : float, default: 0.15
4547
Fraction of original axes to use for colorbar.
48+
4649
shrink : float, default: 1.0
4750
Fraction by which to multiply the size of the colorbar.
51+
4852
aspect : float, default: 20
4953
Ratio of long to short dimensions.
54+
5055
pad : float, default: 0.05 if vertical, 0.15 if horizontal
5156
Fraction of original axes between colorbar and new image axes.
57+
5258
anchor : (float, float), optional
5359
The anchor point of the colorbar axes.
5460
Defaults to (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal.
61+
5562
panchor : (float, float), or *False*, optional
5663
The anchor point of the colorbar parent axes. If *False*, the parent
5764
axes' anchor will be unchanged.
5865
Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal.
5966
"""
6067

6168
_colormap_kw_doc = """
62-
63-
============ ====================================================
64-
Property Description
65-
============ ====================================================
66-
*extend* {'neither', 'both', 'min', 'max'}
67-
If not 'neither', make pointed end(s) for out-of-
68-
range values. These are set for a given colormap
69-
using the colormap set_under and set_over methods.
70-
*extendfrac* {*None*, 'auto', length, lengths}
71-
If set to *None*, both the minimum and maximum
72-
triangular colorbar extensions with have a length of
73-
5% of the interior colorbar length (this is the
74-
default setting). If set to 'auto', makes the
75-
triangular colorbar extensions the same lengths as
76-
the interior boxes (when *spacing* is set to
77-
'uniform') or the same lengths as the respective
78-
adjacent interior boxes (when *spacing* is set to
79-
'proportional'). If a scalar, indicates the length
80-
of both the minimum and maximum triangular colorbar
81-
extensions as a fraction of the interior colorbar
82-
length. A two-element sequence of fractions may also
83-
be given, indicating the lengths of the minimum and
84-
maximum colorbar extensions respectively as a
85-
fraction of the interior colorbar length.
86-
*extendrect* bool
87-
If *False* the minimum and maximum colorbar extensions
88-
will be triangular (the default). If *True* the
89-
extensions will be rectangular.
90-
*spacing* {'uniform', 'proportional'}
91-
Uniform spacing gives each discrete color the same
92-
space; proportional makes the space proportional to
93-
the data interval.
94-
*ticks* *None* or list of ticks or Locator
95-
If None, ticks are determined automatically from the
96-
input.
97-
*format* None or str or Formatter
98-
If None, `~.ticker.ScalarFormatter` is used.
99-
If a format string is given, e.g., '%.3f', that is used.
100-
An alternative `~.ticker.Formatter` may be given instead.
101-
*drawedges* bool
102-
Whether to draw lines at color boundaries.
103-
*label* str
104-
The label on the colorbar's long axis.
105-
============ ====================================================
106-
107-
The following will probably be useful only in the context of
108-
indexed colors (that is, when the mappable has norm=NoNorm()),
109-
or other unusual circumstances.
110-
111-
============ ===================================================
112-
Property Description
113-
============ ===================================================
114-
*boundaries* None or a sequence
115-
*values* None or a sequence which must be of length 1 less
116-
than the sequence of *boundaries*. For each region
117-
delimited by adjacent entries in *boundaries*, the
118-
colormapped to the corresponding value in values
119-
will be used.
120-
============ ===================================================
121-
69+
extend : {'neither', 'both', 'min', 'max'}
70+
Make pointed end(s) for out-of-range values (unless 'neither'). These are
71+
set for a given colormap using the colormap set_under and set_over methods.
72+
73+
extendfrac : {*None*, 'auto', length, lengths}
74+
If set to *None*, both the minimum and maximum triangular colorbar
75+
extensions will have a length of 5% of the interior colorbar length (this
76+
is the default setting).
77+
78+
If set to 'auto', makes the triangular colorbar extensions the same lengths
79+
as the interior boxes (when *spacing* is set to 'uniform') or the same
80+
lengths as the respective adjacent interior boxes (when *spacing* is set to
81+
'proportional').
82+
83+
If a scalar, indicates the length of both the minimum and maximum
84+
triangular colorbar extensions as a fraction of the interior colorbar
85+
length. A two-element sequence of fractions may also be given, indicating
86+
the lengths of the minimum and maximum colorbar extensions respectively as
87+
a fraction of the interior colorbar length.
88+
89+
extendrect : bool
90+
If *False* the minimum and maximum colorbar extensions will be triangular
91+
(the default). If *True* the extensions will be rectangular.
92+
93+
spacing : {'uniform', 'proportional'}
94+
For discrete colorbars (`.BoundaryNorm` or contours), 'uniform' gives each
95+
color the same space; 'proportional' makes the space proportional to the
96+
data interval.
97+
98+
ticks : None or list of ticks or Locator
99+
If None, ticks are determined automatically from the input.
100+
101+
format : None or str or Formatter
102+
If None, `~.ticker.ScalarFormatter` is used.
103+
Format strings, e.g., ``"%4.2e"`` or ``"{x:.2e}"``, are supported.
104+
An alternative `~.ticker.Formatter` may be given instead.
105+
106+
drawedges : bool
107+
Whether to draw lines at color boundaries.
108+
109+
label : str
110+
The label on the colorbar's long axis.
111+
112+
boundaries, values : None or a sequence
113+
If unset, the colormap will be displayed on a 0-1 scale.
114+
If sequences, *values* must have a length 1 less than *boundaries*. For
115+
each region delimited by adjacent entries in *boundaries*, the color mapped
116+
to the corresponding value in values will be used.
117+
Normally only useful for indexed colors (i.e. ``norm=NoNorm()``) or other
118+
unusual circumstances.
122119
"""
123120

124121
docstring.interpd.update(colorbar_doc="""
@@ -186,7 +183,8 @@
186183
However this has negative consequences in other circumstances, e.g. with
187184
semi-transparent images (alpha < 1) and colorbar extensions; therefore, this
188185
workaround is not used by default (see issue #1188).
189-
""" % (textwrap.indent(_make_axes_kw_doc, " "), _colormap_kw_doc))
186+
""" % (textwrap.indent(_make_axes_kw_doc, " "),
187+
textwrap.indent(_colormap_kw_doc, " ")))
190188

191189

192190
def _set_ticks_on_axis_warn(*args, **kwargs):
@@ -273,6 +271,7 @@ def get_subplotspec(self):
273271
return ss
274272

275273

274+
@docstring.Substitution(_colormap_kw_doc)
276275
class Colorbar:
277276
r"""
278277
Draw a colorbar in an existing axes.
@@ -325,32 +324,14 @@ class Colorbar:
325324
alpha : float
326325
The colorbar transparency between 0 (transparent) and 1 (opaque).
327326
328-
values, boundaries
329-
If unset, the colormap will be displayed on a 0-1 scale.
330-
331327
orientation : {'vertical', 'horizontal'}
332328
333329
ticklocation : {'auto', 'left', 'right', 'top', 'bottom'}
334330
335-
extend : {'neither', 'both', 'min', 'max'}
336-
337-
spacing : {'uniform', 'proportional'}
338-
339-
ticks : `~matplotlib.ticker.Locator` or array-like of float
340-
341-
format : str or `~matplotlib.ticker.Formatter`
342-
If string, it supports '%' operator and `str.format` formats:
343-
e.g. ``"%4.2e"`` or ``"{x:.2e}"``.
344-
345331
drawedges : bool
346332
347333
filled : bool
348-
349-
extendfrac
350-
351-
extendrec
352-
353-
label : str
334+
%s
354335
"""
355336

356337
n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize

0 commit comments

Comments
 (0)