colorbar_wrapper¶
-
colorbar_wrapper
(self, mappable, values=None, extend=None, extendsize=None, title=None, label=None, grid=None, tickminor=None, reverse=False, tickloc=None, ticklocation=None, locator=None, ticks=None, maxn=None, maxn_minor=None, minorlocator=None, minorticks=None, locator_kw=None, minorlocator_kw=None, formatter=None, ticklabels=None, formatter_kw=None, norm=None, norm_kw=None, orientation='horizontal', edgecolor=None, linewidth=None, labelsize=None, labelweight=None, labelcolor=None, ticklabelsize=None, ticklabelweight=None, ticklabelcolor=None, **kwargs)[source]¶ Adds useful features for controlling colorbars.
Note
This function wraps
proplot.axes.Axes.legend
andproplot.figure.Figure.legend
.- Parameters
mappable (mappable, list of plot handles, list of color-spec, or colormap-spec) – There are four options here:
A mappable object. Basically, any object with a
get_cmap
method, like the objects returned bycontourf
andpcolormesh
.A list of “plot handles”. Basically, any object with a
get_color
method, likeLine2D
instances. A colormap will be generated from the colors of these objects, and colorbar levels will be selected usingvalues
. Ifvalues
isNone
, we try to infer them by converting the handle labels returned byget_label
tofloat
. Otherwise, it is set tonp.linspace(0, 1, len(mappable))
.A list of hex strings, color string names, or RGB tuples. A colormap will be generated from these colors, and colorbar levels will be selected using
values
. Ifvalues
isNone
, it is set tonp.linspace(0, 1, len(mappable))
.A
Colormap
instance. In this case, a colorbar will be drawn using this colormap and with levels determined byvalues
. Ifvalues
isNone
, it is set tonp.linspace(0, 1, cmap.N)
.
values (list of float, optional) – Ignored if
mappable
is a mappable object. This maps each color or plot handle in themappable
list to numeric values, from which a colormap and normalizer are constructed.norm (normalizer spec, optional) – Ignored if
values
isNone
. The normalizer for convertingvalues
to colormap colors. Passed toNorm
.norm_kw (dict-like, optional) – The normalizer settings. Passed to
Norm
.extend ({None, ‘neither’, ‘both’, ‘min’, ‘max’}, optional) – Direction for drawing colorbar “extensions” (i.e. references to out-of-bounds data with a unique color). These are triangles by default. If
None
, we try to use theextend
attribute on the mappable object. If the attribute is unavailable, we use'neither'
.extendsize (float or str, optional) – The length of the colorbar “extensions” in physical units. If float, units are inches. If string, units are interpreted by
units
. Default isrc[‘colorbar.insetextend’]
='1em'
for inset colorbars andrc[‘colorbar.extend’]
='1.3em'
for outer colorbars.reverse (bool, optional) – Whether to reverse the direction of the colorbar.
tickloc, ticklocation ({‘bottom’, ‘top’, ‘left’, ‘right’}, optional) – Where to draw tick marks on the colorbar.
tickminor (bool, optional) – Whether to add minor ticks to the colorbar with
minorticks_on
.label, title (str, optional) – The colorbar label. The
title
keyword is also accepted for consistency withlegend
.grid (bool, optional) – Whether to draw “gridlines” between each level of the colorbar. Default is
rc[‘colorbar.grid’]
=False
.locator, ticks (locator spec, optional) – Used to determine the colorbar tick positions. Passed to the
Locator
constructor.maxn (int, optional) – Used if
locator
isNone
. Determines the maximum number of levels that are ticked. Default depends on the colorbar length relative to the font size. The keyword name “maxn” is meant to mimic theMaxNLocator
class name.locator_kw (dict-like, optional) – The locator settings. Passed to
Locator
.minorlocator, minorticks, maxn_minor, minorlocator_kw – As with
locator
,maxn
, andlocator_kw
, but for the minor ticks.formatter, ticklabels (formatter spec, optional) – The tick label format. Passed to the
Formatter
constructor.formatter_kw (dict-like, optional) – The formatter settings. Passed to
Formatter
.edgecolor, linewidth (optional) – The edge color and line width for the colorbar outline.
labelsize, labelweight, labelcolor (optional) – The font size, weight, and color for colorbar label text.
ticklabelsize, ticklabelweight, ticklabelcolor (optional) – The font size, weight, and color for colorbar tick labels.
orientation ({{‘horizontal’, ‘vertical’}}, optional) – The colorbar orientation. You should not have to explicitly set this.
- Other Parameters
**kwargs – Passed to
colorbar
.