@@ -350,40 +350,77 @@ def get_clim(self):
350
350
351
351
352
352
class ColorbarBase (_ColorbarMappableDummy ):
353
- '''
353
+ r"""
354
354
Draw a colorbar in an existing axes.
355
355
356
- This is a base class for the :class:`Colorbar` class, which is the
357
- basis for the :func:`~matplotlib.pyplot.colorbar` function and the
358
- :meth:`~matplotlib.figure.Figure.colorbar` method, which are the
359
- usual ways of creating a colorbar.
356
+ There are only some rare cases in which you would work directly with a
357
+ `.ColorbarBase` as an end-user. Typically, colorbars are used
358
+ with `.ScalarMappable`\s such as an `.AxesImage` generated via
359
+ `~.axes.Axes.imshow`. For these cases you will use `.Colorbar` and
360
+ likely create it via `.pyplot.colorbar` or `.Figure.colorbar`.
361
+
362
+ The main application of using a `.ColorbarBase` explicitly is drawing
363
+ colorbars that are not associated with other elements in the figure, e.g.
364
+ when showing a colormap by itself.
360
365
361
- It is also useful by itself for showing a colormap. If the *cmap*
362
- kwarg is given but *boundaries* and *values* are left as None,
363
- then the colormap will be displayed on a 0-1 scale. To show the
366
+ If the *cmap* kwarg is given but *boundaries* and *values* are left as
367
+ None, then the colormap will be displayed on a 0-1 scale. To show the
364
368
under- and over-value colors, specify the *norm* as::
365
369
366
- colors.Normalize(clip=False)
370
+ norm= colors.Normalize(clip=False)
367
371
368
372
To show the colors versus index instead of on the 0-1 scale,
369
373
use::
370
374
371
- norm=colors.NoNorm.
375
+ norm=colors.NoNorm
372
376
373
377
Useful public methods are :meth:`set_label` and :meth:`add_lines`.
374
378
375
379
Attributes
376
380
----------
377
- ax : Axes
378
- The `Axes` instance in which the colorbar is drawn.
379
-
381
+ ax : `~matplotlib.axes.Axes`
382
+ The `~.axes.Axes` instance in which the colorbar is drawn.
380
383
lines : list
381
- A list of `LineCollection` if lines were drawn, otherwise
384
+ A list of `. LineCollection` if lines were drawn, otherwise
382
385
an empty list.
383
-
384
- dividers : LineCollection
386
+ dividers : `.LineCollection`
385
387
A LineCollection if *drawedges* is ``True``, otherwise ``None``.
386
- '''
388
+
389
+ Parameters
390
+ ----------
391
+ ax : `~matplotlib.axes.Axes`
392
+ The `~.axes.Axes` instance in which the colorbar is drawn.
393
+ cmap : `~matplotlib.colors.Colormap` or None
394
+ The colormap to use. If *None*, use :rc:`image.cmap`.
395
+ norm : `~matplotlib.colors.Normalize`
396
+ alpha : float
397
+
398
+ values
399
+
400
+ boundaries
401
+
402
+ orientation : {'vertical', 'horizontal'}
403
+
404
+ ticklocation : {'auto', 'left', 'right', 'top', 'bottom'}
405
+
406
+ extend : {'neiter', 'both', 'min', 'max'}
407
+
408
+ spacing : {'uniform', 'proportional'}
409
+
410
+ ticks : `~matplotlib.ticker.Locator` or array-like of float
411
+
412
+ format : str or `~matplotlib.ticker.Formatter`
413
+
414
+ drawedges : bool
415
+
416
+ filled : bool
417
+
418
+ extendfrac
419
+
420
+ extendrec
421
+
422
+ label : str
423
+ """
387
424
_slice_dict = {'neither' : slice (0 , None ),
388
425
'both' : slice (1 , - 1 ),
389
426
'min' : slice (1 , None ),
@@ -408,7 +445,17 @@ def __init__(self, ax, cmap=None,
408
445
extendrect = False ,
409
446
label = '' ,
410
447
):
411
- #: The axes that this colorbar lives in.
448
+ cbook ._check_isinstance ([colors .Colormap , None ], cmap = cmap )
449
+ cbook ._check_in_list (
450
+ ['vertical' , 'horizontal' ], orientation = orientation )
451
+ cbook ._check_in_list (
452
+ ['auto' , 'left' , 'right' , 'top' , 'bottom' ],
453
+ ticklocation = ticklocation )
454
+ cbook ._check_in_list (
455
+ self ._slice_dict , extend = extend )
456
+ cbook ._check_in_list (
457
+ ['uniform' , 'proportional' ], spacing = spacing )
458
+
412
459
self .ax = ax
413
460
self ._patch_ax ()
414
461
if cmap is None :
0 commit comments