Skip to content

Commit efde717

Browse files
authored
Merge pull request matplotlib#29652 from anntzer/cbd
Reorder kwonly kwargs in Colorbar & related docs.
2 parents 9643551 + e65902f commit efde717

File tree

1 file changed

+33
-38
lines changed

1 file changed

+33
-38
lines changed

lib/matplotlib/colorbar.py

+33-38
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,26 @@ class Colorbar:
226226
mappable : `.ScalarMappable`
227227
The mappable whose colormap and norm will be used.
228228
229-
To show the under- and over- value colors, the mappable's norm should
230-
be specified as ::
229+
To show the colors versus index instead of on a 0-1 scale, set the
230+
mappable's norm to ``colors.NoNorm()``.
231231
232-
norm = colors.Normalize(clip=False)
232+
alpha : float
233+
The colorbar transparency between 0 (transparent) and 1 (opaque).
234+
235+
location : None or {'left', 'right', 'top', 'bottom'}
236+
Set the colorbar's *orientation* and *ticklocation*. Colorbars on
237+
the left and right are vertical, colorbars at the top and bottom
238+
are horizontal. The *ticklocation* is the same as *location*, so if
239+
*location* is 'top', the ticks are on the top. *orientation* and/or
240+
*ticklocation* can be provided as well and overrides the value set by
241+
*location*, but there will be an error for incompatible combinations.
233242
234-
To show the colors versus index instead of on a 0-1 scale, use::
243+
.. versionadded:: 3.7
235244
236-
norm=colors.NoNorm()
245+
%(_colormap_kw_doc)s
237246
247+
Other Parameters
248+
----------------
238249
cmap : `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
239250
The colormap to use. This parameter is ignored, unless *mappable* is
240251
None.
@@ -243,9 +254,6 @@ class Colorbar:
243254
The normalization to use. This parameter is ignored, unless *mappable*
244255
is None.
245256
246-
alpha : float
247-
The colorbar transparency between 0 (transparent) and 1 (opaque).
248-
249257
orientation : None or {'vertical', 'horizontal'}
250258
If None, use the value determined by *location*. If both
251259
*orientation* and *location* are None then defaults to 'vertical'.
@@ -257,40 +265,27 @@ class Colorbar:
257265
*location*, so a colorbar to the left will have ticks to the left. If
258266
*location* is None, the ticks will be at the bottom for a horizontal
259267
colorbar and at the right for a vertical.
260-
261-
%(_colormap_kw_doc)s
262-
263-
location : None or {'left', 'right', 'top', 'bottom'}
264-
Set the *orientation* and *ticklocation* of the colorbar using a
265-
single argument. Colorbars on the left and right are vertical,
266-
colorbars at the top and bottom are horizontal. The *ticklocation* is
267-
the same as *location*, so if *location* is 'top', the ticks are on
268-
the top. *orientation* and/or *ticklocation* can be provided as well
269-
and overrides the value set by *location*, but there will be an error
270-
for incompatible combinations.
271-
272-
.. versionadded:: 3.7
273268
"""
274269

275270
n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize
276271

277-
def __init__(self, ax, mappable=None, *, cmap=None,
278-
norm=None,
279-
alpha=None,
280-
values=None,
281-
boundaries=None,
282-
orientation=None,
283-
ticklocation='auto',
284-
extend=None,
285-
spacing='uniform', # uniform or proportional
286-
ticks=None,
287-
format=None,
288-
drawedges=False,
289-
extendfrac=None,
290-
extendrect=False,
291-
label='',
292-
location=None,
293-
):
272+
def __init__(
273+
self, ax, mappable=None, *,
274+
alpha=None,
275+
location=None,
276+
extend=None,
277+
extendfrac=None,
278+
extendrect=False,
279+
ticks=None,
280+
format=None,
281+
values=None,
282+
boundaries=None,
283+
spacing='uniform',
284+
drawedges=False,
285+
label='',
286+
cmap=None, norm=None, # redundant with *mappable*
287+
orientation=None, ticklocation='auto', # redundant with *location*
288+
):
294289

295290
if mappable is None:
296291
mappable = cm.ScalarMappable(norm=norm, cmap=cmap)

0 commit comments

Comments
 (0)