colorbar_wrapper¶
-
colorbar_wrapper(self, mappable, values=None, extend=None, extendsize=None, title=None, label=None, grid=None, tickminor=None, 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, fixticks=False, **kwargs)[source]¶ Wraps
AxescolorbarandFigurecolorbar, adds some handy features.- 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_cmapmethod, like the objects returned bycontourfandpcolormesh.A list of “plot handles”. Basically, any object with a
get_colormethod, likeLine2Dinstances. A colormap will be generated from the colors of these objects, and colorbar levels will be selected usingvalues. IfvaluesisNone, we try to infer them by converting the handle labels returned byget_labeltofloat. 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. IfvaluesisNone, it is set tonp.linspace(0, 1, len(mappable)).A
Colormapinstance. In this case, a colorbar will be drawn using this colormap and with levels determined byvalues. IfvaluesisNone, it is set tonp.linspace(0, 1, cmap._N).
values (list of float, optional) – Ignored if
mappableis a mappable object. This maps each color or plot handle in themappablelist to numeric values, from which a colormap and normalizer are constructed.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 theextendattribute 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.This is handy if you have multiple colorbars in one figure. With the matplotlib API, it is really hard to get triangle sizes to match, because the
extendsizeunits are relative.tickloc, ticklocation ({‘bottom’, ‘top’, ‘left’, ‘right’}, optional) – Where to draw tick marks on the colorbar.
label, title (str, optional) – The colorbar label. The
titlekeyword 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.tickminor (bool, optional) – Whether to put minor ticks on the colorbar. Default is
False.locator, ticks (locator spec, optional) – Used to determine the colorbar tick mark positions. Passed to the
Locatorconstructor.maxn (int, optional) – Used if
locatorisNone. 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 theMaxNLocatorclass name.maxn_minor (int, optional) – As with
maxn, but for minor tick positions. Default depends on the colorbar length.locator_kw (dict-like, optional) – The locator settings. Passed to
Locator.minorlocator, minorticks – As with
locator, but for the minor tick marks.minorlocator_kw – As for
locator_kw, but for the minor locator.formatter, ticklabels (formatter spec, optional) – The tick label format. Passed to the
Formatterconstructor.formatter_kw (dict-like, optional) – The formatter settings. Passed to
Formatter.norm (normalizer spec, optional) – Ignored if
valuesisNone. The normalizer for convertingvaluesto colormap colors. Passed to theNormconstructor. As an example, if your values are logarithmically spaced but you want the level boundaries to appear halfway in-between the colorbar tick marks, trynorm='log'.norm_kw (dict-like, optional) – The normalizer settings. Passed to
Norm.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.
fixticks (bool, optional) – For complicated normalizers (e.g.
LogNorm), the colorbar minor and major ticks can appear misaligned. WhenfixticksisTrue, this misalignment is fixed. Default isFalse.This will give incorrect positions when the colormap index does not appear to vary “linearly” from left-to-right across the colorbar (for example, when the leftmost colormap colors seem to be “pulled” to the right farther than normal). In this case, you should stick with
fixticks=False.orientation ({‘horizontal’, ‘vertical’}, optional) – The colorbar orientation. You should not have to explicitly set this.
- Other Parameters
**kwargs – Passed to
colorbar.