matplotlib 3.5.1

AttributesParametersBackRef

Attributes

ax : `~matplotlib.axes.Axes`

The :None:None:`~.axes.Axes` instance in which the colorbar is drawn.

lines : list

A list of .LineCollection (empty if no lines were drawn).

dividers : `.LineCollection`

A LineCollection (empty if drawedges is False ).

Typically, colorbars are created using :None:None:`.Figure.colorbar` or .pyplot.colorbar and associated with .ScalarMappable \s (such as an .AxesImage generated via :None:None:`~.axes.Axes.imshow`).

In order to draw a colorbar not associated with other elements in the figure, e.g. when showing a colormap by itself, one can create an empty .ScalarMappable , or directly pass cmap and norm instead of mappable to Colorbar .

Useful public methods are set_label and add_lines .

Parameters

ax : `~matplotlib.axes.Axes`

The :None:None:`~.axes.Axes` instance in which the colorbar is drawn.

mappable : `.ScalarMappable`

The mappable whose colormap and norm will be used.

To show the under- and over- value colors, the mappable's norm should be specified as :

norm = colors.Normalize(clip=False)

To show the colors versus index instead of on a 0-1 scale, use:

norm=colors.NoNorm()
cmap : `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`

The colormap to use. This parameter is ignored, unless mappable is None.

norm : `~matplotlib.colors.Normalize`

The normalization to use. This parameter is ignored, unless mappable is None.

alpha : float

The colorbar transparency between 0 (transparent) and 1 (opaque).

values, boundaries :

If unset, the colormap will be displayed on a 0-1 scale.

orientation : {'vertical', 'horizontal'}
ticklocation : {'auto', 'left', 'right', 'top', 'bottom'}
extend : {'neither', 'both', 'min', 'max'}
spacing : {'uniform', 'proportional'}
ticks : `~matplotlib.ticker.Locator` or array-like of float
format : str or `~matplotlib.ticker.Formatter`
drawedges : bool
filled : bool
extendfrac :
extendrec :
label : str

Draw a colorbar in an existing axes.

Examples

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

matplotlib.colorbar.Colorbar matplotlib.colors.BoundaryNorm.__init__

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /matplotlib/colorbar.py#291
type: <class 'type'>
Commit: