set_norm(norm)[source]

Set the normalization instance.  Parameters

normNormalize or None

   Notes If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.


set_offset_transform(transOffset)[source]

Set the artist offset transform.  Parameters

transOffsetTransform


set_offsets(offsets)[source]

Set the offsets for the collection.  Parameters

offsets(N, 2) or (2,) array-like


set_path_effects(path_effects)[source]

Set the path effects.  Parameters

path_effectsAbstractPathEffect


set_picker(picker)[source]

Define the picking behavior of the artist.  Parameters

pickerNone or bool or float or callable

This can be one of the following:
None: Picking is disabled for this artist (default). A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist. A float: If picker is a number it is interpreted as an epsilon tolerance in points and the artist will fire off an event if its data is within epsilon of the mouse event. For some artists like lines and patch collections, the artist may provide additional data to the pick event that is generated, e.g., the indices of the data within epsilon of the pick event
A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event: hit, props = picker(artist, mouseevent)
 to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.


set_pickradius(pr)[source]

Set the pick radius used for containment tests.  Parameters

prfloat

Pick radius, in points.


set_rasterized(rasterized)[source]

Force rasterized (bitmap) drawing for vector graphics output. Rasterized drawing is not supported by all artists. If you try to enable this on an artist that does not support it, the command has no effect and a warning will be issued. This setting is ignored for pixel-based output. See also Rasterization for vector graphics.  Parameters

rasterizedbool


set_sketch_params(scale=None, length=None, randomness=None)[source]

Set the sketch parameters.  Parameters

scalefloat, optional

The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is None, or not provided, no sketch filter will be provided.
lengthfloat, optional

The length of the wiggle along the line, in pixels (default 128.0)
randomnessfloat, optional

The scale factor by which the length is shrunken or expanded (default 16.0) The PGF backend uses this argument as an RNG seed and not as described above. Using the same seed yields the same random shape.


set_snap(snap)[source]

Set the snapping behavior. Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line. Snapping is currently only supported by the Agg and MacOSX backends.  Parameters

snapbool or None

Possible values:
True: Snap vertices to the nearest pixel center.
False: Do not modify vertex positions.
None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.


set_transform(t)[source]

Set the artist transform.  Parameters

tTransform


set_url(url)[source]

Set the url for the artist.  Parameters

urlstr


set_urls(urls)[source]

 Parameters

urlslist of str or None

   Notes URLs are currently only implemented by the SVG backend. They are ignored by all other backends.


set_visible(b)[source]

Set the artist's visibility.  Parameters

bbool


set_zorder(level)[source]

Set the zorder for the artist. Artists with lower zorder values are drawn first.  Parameters

levelfloat


to_rgba(x, alpha=None, bytes=False, norm=True)[source]

Return a normalized rgba array corresponding to x. In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable. There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4. In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range. If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).


update(props)[source]

Update this artist's properties from the dict props.  Parameters

propsdict


update_from(other)[source]

Copy properties from other to self.


update_scalarmappable()[source]

Update colors from the scalar mappable array, if any. Assign colors to edges and faces based on the array and/or colors that were directly set, as appropriate.


matplotlib.colorbar Colorbars are a visualization of the mapping from scalar values to colors. In Matplotlib they are drawn into a dedicated Axes.  Note Colorbars are typically created through Figure.colorbar or its pyplot wrapper pyplot.colorbar, which internally use Colorbar together with make_axes_gridspec (for GridSpec-positioned axes) or make_axes (for non-GridSpec-positioned axes). End-users most likely won't need to directly use this module's API.    classmatplotlib.colorbar.Colorbar(ax, mappable=None, *, cmap=None, norm=None, alpha=None, values=None, boundaries=None, orientation='vertical', ticklocation='auto', extend=None, spacing='uniform', ticks=None, format=None, drawedges=False, filled=True, extendfrac=None, extendrect=False, label='')[source]

Bases: object Draw a colorbar in an existing axes. Typically, colorbars are created using Figure.colorbar or pyplot.colorbar and associated with ScalarMappables (such as an AxesImage generated via 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

axAxes

The Axes instance in which the colorbar is drawn.
mappableScalarMappable

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()

cmapColormap, default: rcParams["image.cmap"] (default: 'viridis')

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

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

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'}

ticksLocator or array-like of float

formatstr or Formatter

drawedgesbool

filledbool

extendfrac
extendrec

labelstr

  Attributes

axAxes

The Axes instance in which the colorbar is drawn.
lineslist

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

A LineCollection (empty if drawedges is False).       add_lines(*args, **kwargs)[source]

Draw lines on the colorbar. The lines are appended to the list lines.  Parameters

levelsarray-like

The positions of the lines.
colorscolor or list of colors

Either a single color applying to all lines or one color value for each line.
linewidthsfloat or array-like

Either a single linewidth applying to all lines or one linewidth for each line.
erasebool, default: True

Whether to remove any previously added lines.     Notes Alternatively, this method can also be called with the signature colorbar.add_lines(contour_set, erase=True), in which case levels, colors, and linewidths are taken from contour_set.
   drag_pan(button, key, x, y)[source]

   draw_all()[source]

Calculate any free parameters based on the current cmap and norm, and do all the drawing.
   get_ticks(minor=False)[source]

Return the ticks as a list of locations.  Parameters

minorboolean, default: False

if True return the minor ticks.
   minorticks_off()[source]

Turn the minor ticks of the colorbar off.
   minorticks_on()[source]

Turn on colorbar minor ticks.
   n_rasterize=50

   propertypatch[source]

   remove()[source]

Remove this colorbar from the figure. If the colorbar was created with use_gridspec=True the previous gridspec is restored.
   set_alpha(alpha)[source]

Set the transparency between 0 (transparent) and 1 (opaque). If an array is provided, alpha will be set to None to use the transparency values associated with the colormap.
   set_label(label, *, loc=None, **kwargs)[source]

Add a label to the long axis of the colorbar.  Parameters

labelstr

The label text.
locstr, optional

The location of the label.  For horizontal orientation one of {'left', 'center', 'right'} For vertical orientation one of {'bottom', 'center', 'top'}  Defaults to rcParams["xaxis.labellocation"] (default: 'center') or rcParams["yaxis.labellocation"] (default: 'center') depending on the orientation.  **kwargs

Keyword arguments are passed to set_xlabel / set_ylabel. Supported keywords are labelpad and Text properties.
   set_ticklabels(ticklabels, update_ticks=<deprecated parameter>, *, minor=False, **kwargs)[source]

Set tick labels.  Discouraged The use of this method is discouraged, because of the dependency on tick positions. In most cases, you'll want to use set_ticks(positions, labels=labels) instead. If you are using this method, you should always fix the tick positions before, e.g. by using Colorbar.set_ticks or by explicitly setting a FixedLocator on the long axis of the colorbar. Otherwise, ticks are free to move and the labels may end up in unexpected positions.   Parameters

ticklabelssequence of str or of Text

Texts for labeling each tick location in the sequence set by Colorbar.set_ticks; the number of labels must match the number of locations.
update_ticksbool, default: True

 This keyword argument is ignored and will be be removed. Deprecated  minorbool

If True, set minor ticks instead of major ticks.    **kwargs

Text properties for the labels.
   set_ticks(ticks, update_ticks=<deprecated parameter>, labels=None, *, minor=False, **kwargs)[source]

Set tick locations.  Parameters

tickslist of floats

List of tick locations.
labelslist of str, optional

List of tick labels. If not set, the labels show the data value.
minorbool, default: False

If False, set the major ticks; if True, the minor ticks.  **kwargs

Text properties for the labels. These take effect only if you pass labels. In other cases, please use tick_params.
   update_normal(mappable)[source]

Update solid patches, lines, etc. This is meant to be called when the norm of the image or contour plot to which this colorbar belongs changes. If the norm on the mappable is different than before, this resets the locator and formatter for the axis, so if these have been customized, they will need to be customized again. However, if the norm only changes values of vmin, vmax or cmap then the old formatter and locator will be preserved.
   update_ticks()[source]

Setup the ticks and ticklabels. This should not be needed by users.

   matplotlib.colorbar.ColorbarBase[source]

alias of matplotlib.colorbar.Colorbar
   classmatplotlib.colorbar.ColorbarPatch(ax, mappable=None, *, cmap=None, norm=None, alpha=None, values=None, boundaries=None, orientation='vertical', ticklocation='auto', extend=None, spacing='uniform', ticks=None, format=None, drawedges=False, filled=True, extendfrac=None, extendrect=False, label='')[source]

Bases: matplotlib.colorbar.Colorbar [Deprecated] Notes  Deprecated since version 3.4:
   matplotlib.colorbar.colorbar_factory(cax, mappable, **kwargs)[source]

[Deprecated] Create a colorbar on the given axes for the given mappable.  Note This is a low-level function to turn an existing axes into a colorbar axes. Typically, you'll want to use colorbar instead, which automatically handles creation and placement of a suitable axes as well.   Parameters

caxAxes

The Axes to turn into a colorbar.
mappableScalarMappable

The mappable to be described by the colorbar.  **kwargs

Keyword arguments are passed to the respective colorbar class.    Returns
 Colorbar

The created colorbar instance.     Notes  Deprecated since version 3.4.
   matplotlib.colorbar.make_axes(parents, location=None, orientation=None, fraction=0.15, shrink=1.0, aspect=20, **kw)[source]

Create an Axes suitable for a colorbar. The axes is placed in the figure of the parents axes, by resizing and repositioning parents.  Parameters

parentsAxes or list of Axes

The Axes to use as parents for placing the colorbar.
locationNone or {'left', 'right', 'top', 'bottom'}

The location, relative to the parent axes, where the colorbar axes is created. It also determines the orientation of the colorbar (colorbars on the left and right are vertical, colorbars at the top and bottom are horizontal). If None, the location will come from the orientation if it is set (vertical colorbars on the right, horizontal ones at the bottom), or default to 'right' if orientation is unset.
orientationNone or {'vertical', 'horizontal'}

The orientation of the colorbar. It is preferable to set the location of the colorbar, as that also determines the orientation; passing incompatible values for location and orientation raises an exception.
fractionfloat, default: 0.15

Fraction of original axes to use for colorbar.
shrinkfloat, default: 1.0

Fraction by which to multiply the size of the colorbar.
aspectfloat, default: 20

Ratio of long to short dimensions.    Returns

caxAxes

The child axes.
kwdict

The reduced keyword dictionary to be passed when creating the colorbar instance.    Other Parameters

padfloat, default: 0.05 if vertical, 0.15 if horizontal

Fraction of original axes between colorbar and new image axes.
anchor(float, float), optional

The anchor point of the colorbar axes. Defaults to (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal.
panchor(float, float), or False, optional

The anchor point of the colorbar parent axes. If False, the parent axes' anchor will be unchanged. Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal.
   matplotlib.colorbar.make_axes_gridspec(parent, *, location=None, orientation=None, fraction=0.15, shrink=1.0, aspect=20, **kw)[source]

Create a SubplotBase suitable for a colorbar. The axes is placed in the figure of the parent axes, by resizing and repositioning parent. This function is similar to make_axes. Primary differences are
make_axes_gridspec should only be used with a SubplotBase parent.
make_axes creates an Axes; make_axes_gridspec creates a SubplotBase.
make_axes updates the position of the parent. make_axes_gridspec replaces the grid_spec attribute of the parent with a new one.  While this function is meant to be compatible with make_axes, there could be some minor differences.  Parameters

parentAxes

The Axes to use as parent for placing the colorbar.
locationNone or {'left', 'right', 'top', 'bottom'}

The location, relative to the parent axes, where the colorbar axes is created. It also determines the orientation of the colorbar (colorbars on the left and right are vertical, colorbars at the top and bottom are horizontal). If None, the location will come from the orientation if it is set (vertical colorbars on the right, horizontal ones at the bottom), or default to 'right' if orientation is unset.
orientationNone or {'vertical', 'horizontal'}

The orientation of the colorbar. It is preferable to set the location of the colorbar, as that also determines the orientation; passing incompatible values for location and orientation raises an exception.
fractionfloat, default: 0.15

Fraction of original axes to use for colorbar.
shrinkfloat, default: 1.0

Fraction by which to multiply the size of the colorbar.
aspectfloat, default: 20

Ratio of long to short dimensions.    Returns

caxSubplotBase

The child axes.
kwdict

The reduced keyword dictionary to be passed when creating the colorbar instance.    Other Parameters

padfloat, default: 0.05 if vertical, 0.15 if horizontal

Fraction of original axes between colorbar and new image axes.
anchor(float, float), optional

The anchor point of the colorbar axes. Defaults to (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal.
panchor(float, float), or False, optional

The anchor point of the colorbar parent axes. If False, the parent axes' anchor will be unchanged. Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal.


classmatplotlib.colorbar.Colorbar(ax, mappable=None, *, cmap=None, norm=None, alpha=None, values=None, boundaries=None, orientation='vertical', ticklocation='auto', extend=None, spacing='uniform', ticks=None, format=None, drawedges=False, filled=True, extendfrac=None, extendrect=False, label='')[source]

Bases: object Draw a colorbar in an existing axes. Typically, colorbars are created using Figure.colorbar or pyplot.colorbar and associated with ScalarMappables (such as an AxesImage generated via 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

axAxes

The Axes instance in which the colorbar is drawn.
mappableScalarMappable

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()

cmapColormap, default: rcParams["image.cmap"] (default: 'viridis')

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

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

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'}

ticksLocator or array-like of float

formatstr or Formatter

drawedgesbool

filledbool

extendfrac
extendrec

labelstr

  Attributes

axAxes

The Axes instance in which the colorbar is drawn.
lineslist

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

A LineCollection (empty if drawedges is False).       add_lines(*args, **kwargs)[source]

Draw lines on the colorbar. The lines are appended to the list lines.  Parameters

levelsarray-like

The positions of the lines.
colorscolor or list of colors

Either a single color applying to all lines or one color value for each line.
linewidthsfloat or array-like

Either a single linewidth applying to all lines or one linewidth for each line.
erasebool, default: True

Whether to remove any previously added lines.     Notes Alternatively, this method can also be called with the signature colorbar.add_lines(contour_set, erase=True), in which case levels, colors, and linewidths are taken from contour_set.
   drag_pan(button, key, x, y)[source]

   draw_all()[source]

Calculate any free parameters based on the current cmap and norm, and do all the drawing.
   get_ticks(minor=False)[source]

Return the ticks as a list of locations.  Parameters

minorboolean, default: False

if True return the minor ticks.
   minorticks_off()[source]

Turn the minor ticks of the colorbar off.
   minorticks_on()[source]

Turn on colorbar minor ticks.
   n_rasterize=50

   propertypatch[source]

   remove()[source]

Remove this colorbar from the figure. If the colorbar was created with use_gridspec=True the previous gridspec is restored.
   set_alpha(alpha)[source]

Set the transparency between 0 (transparent) and 1 (opaque). If an array is provided, alpha will be set to None to use the transparency values associated with the colormap.
   set_label(label, *, loc=None, **kwargs)[source]

Add a label to the long axis of the colorbar.  Parameters

labelstr

The label text.
locstr, optional

The location of the label.  For horizontal orientation one of {'left', 'center', 'right'} For vertical orientation one of {'bottom', 'center', 'top'}  Defaults to rcParams["xaxis.labellocation"] (default: 'center') or rcParams["yaxis.labellocation"] (default: 'center') depending on the orientation.  **kwargs

Keyword arguments are passed to set_xlabel / set_ylabel. Supported keywords are labelpad and Text properties.
   set_ticklabels(ticklabels, update_ticks=<deprecated parameter>, *, minor=False, **kwargs)[source]

Set tick labels.  Discouraged The use of this method is discouraged, because of the dependency on tick positions. In most cases, you'll want to use set_ticks(positions, labels=labels) instead. If you are using this method, you should always fix the tick positions before, e.g. by using Colorbar.set_ticks or by explicitly setting a FixedLocator on the long axis of the colorbar. Otherwise, ticks are free to move and the labels may end up in unexpected positions.   Parameters

ticklabelssequence of str or of Text

Texts for labeling each tick location in the sequence set by Colorbar.set_ticks; the number of labels must match the number of locations.
update_ticksbool, default: True

 This keyword argument is ignored and will be be removed. Deprecated  minorbool

If True, set minor ticks instead of major ticks.    **kwargs

Text properties for the labels.
   set_ticks(ticks, update_ticks=<deprecated parameter>, labels=None, *, minor=False, **kwargs)[source]

Set tick locations.  Parameters

tickslist of floats

List of tick locations.
labelslist of str, optional

List of tick labels. If not set, the labels show the data value.
minorbool, default: False

If False, set the major ticks; if True, the minor ticks.  **kwargs

Text properties for the labels. These take effect only if you pass labels. In other cases, please use tick_params.
   update_normal(mappable)[source]

Update solid patches, lines, etc. This is meant to be called when the norm of the image or contour plot to which this colorbar belongs changes. If the norm on the mappable is different than before, this resets the locator and formatter for the axis, so if these have been customized, they will need to be customized again. However, if the norm only changes values of vmin, vmax or cmap then the old formatter and locator will be preserved.
   update_ticks()[source]

Setup the ticks and ticklabels. This should not be needed by users.


add_lines(*args, **kwargs)[source]

Draw lines on the colorbar. The lines are appended to the list lines.  Parameters

levelsarray-like

The positions of the lines.
colorscolor or list of colors

Either a single color applying to all lines or one color value for each line.
linewidthsfloat or array-like

Either a single linewidth applying to all lines or one linewidth for each line.
erasebool, default: True

Whether to remove any previously added lines.     Notes Alternatively, this method can also be called with the signature colorbar.add_lines(contour_set, erase=True), in which case levels, colors, and linewidths are taken from contour_set.


draw_all()[source]

Calculate any free parameters based on the current cmap and norm, and do all the drawing.


get_ticks(minor=False)[source]

Return the ticks as a list of locations.  Parameters

minorboolean, default: False

if True return the minor ticks.


minorticks_off()[source]

Turn the minor ticks of the colorbar off.


minorticks_on()[source]

Turn on colorbar minor ticks.


remove()[source]

Remove this colorbar from the figure. If the colorbar was created with use_gridspec=True the previous gridspec is restored.


set_alpha(alpha)[source]

Set the transparency between 0 (transparent) and 1 (opaque). If an array is provided, alpha will be set to None to use the transparency values associated with the colormap.


set_label(label, *, loc=None, **kwargs)[source]

Add a label to the long axis of the colorbar.  Parameters

labelstr

The label text.
locstr, optional

The location of the label.  For horizontal orientation one of {'left', 'center', 'right'} For vertical orientation one of {'bottom', 'center', 'top'}  Defaults to rcParams["xaxis.labellocation"] (default: 'center') or rcParams["yaxis.labellocation"] (default: 'center') depending on the orientation.  **kwargs

Keyword arguments are passed to set_xlabel / set_ylabel. Supported keywords are labelpad and Text properties.


set_ticklabels(ticklabels, update_ticks=<deprecated parameter>, *, minor=False, **kwargs)[source]

Set tick labels.  Discouraged The use of this method is discouraged, because of the dependency on tick positions. In most cases, you'll want to use set_ticks(positions, labels=labels) instead. If you are using this method, you should always fix the tick positions before, e.g. by using Colorbar.set_ticks or by explicitly setting a FixedLocator on the long axis of the colorbar. Otherwise, ticks are free to move and the labels may end up in unexpected positions.   Parameters

ticklabelssequence of str or of Text

Texts for labeling each tick location in the sequence set by Colorbar.set_ticks; the number of labels must match the number of locations.
update_ticksbool, default: True

 This keyword argument is ignored and will be be removed. Deprecated  minorbool

If True, set minor ticks instead of major ticks.    **kwargs

Text properties for the labels.


set_ticks(ticks, update_ticks=<deprecated parameter>, labels=None, *, minor=False, **kwargs)[source]

Set tick locations.  Parameters

tickslist of floats

List of tick locations.
labelslist of str, optional

List of tick labels. If not set, the labels show the data value.
minorbool, default: False

If False, set the major ticks; if True, the minor ticks.  **kwargs

Text properties for the labels. These take effect only if you pass labels. In other cases, please use tick_params.


update_normal(mappable)[source]

Update solid patches, lines, etc. This is meant to be called when the norm of the image or contour plot to which this colorbar belongs changes. If the norm on the mappable is different than before, this resets the locator and formatter for the axis, so if these have been customized, they will need to be customized again. However, if the norm only changes values of vmin, vmax or cmap then the old formatter and locator will be preserved.


update_ticks()[source]

Setup the ticks and ticklabels. This should not be needed by users.


matplotlib.colorbar.colorbar_factory(cax, mappable, **kwargs)[source]

[Deprecated] Create a colorbar on the given axes for the given mappable.  Note This is a low-level function to turn an existing axes into a colorbar axes. Typically, you'll want to use colorbar instead, which automatically handles creation and placement of a suitable axes as well.   Parameters

caxAxes

The Axes to turn into a colorbar.
mappableScalarMappable

The mappable to be described by the colorbar.  **kwargs

Keyword arguments are passed to the respective colorbar class.    Returns
 Colorbar

The created colorbar instance.     Notes  Deprecated since version 3.4.


matplotlib.colorbar.ColorbarBase[source]

alias of matplotlib.colorbar.Colorbar


classmatplotlib.colorbar.ColorbarPatch(ax, mappable=None, *, cmap=None, norm=None, alpha=None, values=None, boundaries=None, orientation='vertical', ticklocation='auto', extend=None, spacing='uniform', ticks=None, format=None, drawedges=False, filled=True, extendfrac=None, extendrect=False, label='')[source]

Bases: matplotlib.colorbar.Colorbar [Deprecated] Notes  Deprecated since version 3.4:


matplotlib.colorbar.make_axes(parents, location=None, orientation=None, fraction=0.15, shrink=1.0, aspect=20, **kw)[source]

Create an Axes suitable for a colorbar. The axes is placed in the figure of the parents axes, by resizing and repositioning parents.  Parameters

parentsAxes or list of Axes

The Axes to use as parents for placing the colorbar.
locationNone or {'left', 'right', 'top', 'bottom'}

The location, relative to the parent axes, where the colorbar axes is created. It also determines the orientation of the colorbar (colorbars on the left and right are vertical, colorbars at the top and bottom are horizontal). If None, the location will come from the orientation if it is set (vertical colorbars on the right, horizontal ones at the bottom), or default to 'right' if orientation is unset.
orientationNone or {'vertical', 'horizontal'}

The orientation of the colorbar. It is preferable to set the location of the colorbar, as that also determines the orientation; passing incompatible values for location and orientation raises an exception.
fractionfloat, default: 0.15

Fraction of original axes to use for colorbar.
shrinkfloat, default: 1.0

Fraction by which to multiply the size of the colorbar.
aspectfloat, default: 20

Ratio of long to short dimensions.    Returns

caxAxes

The child axes.
kwdict

The reduced keyword dictionary to be passed when creating the colorbar instance.    Other Parameters

padfloat, default: 0.05 if vertical, 0.15 if horizontal

Fraction of original axes between colorbar and new image axes.
anchor(float, float), optional

The anchor point of the colorbar axes. Defaults to (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal.
panchor(float, float), or False, optional

The anchor point of the colorbar parent axes. If False, the parent axes' anchor will be unchanged. Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal.


matplotlib.colorbar.make_axes_gridspec(parent, *, location=None, orientation=None, fraction=0.15, shrink=1.0, aspect=20, **kw)[source]

Create a SubplotBase suitable for a colorbar. The axes is placed in the figure of the parent axes, by resizing and repositioning parent. This function is similar to make_axes. Primary differences are
make_axes_gridspec should only be used with a SubplotBase parent.
make_axes creates an Axes; make_axes_gridspec creates a SubplotBase.
make_axes updates the position of the parent. make_axes_gridspec replaces the grid_spec attribute of the parent with a new one.  While this function is meant to be compatible with make_axes, there could be some minor differences.  Parameters

parentAxes

The Axes to use as parent for placing the colorbar.
locationNone or {'left', 'right', 'top', 'bottom'}

The location, relative to the parent axes, where the colorbar axes is created. It also determines the orientation of the colorbar (colorbars on the left and right are vertical, colorbars at the top and bottom are horizontal). If None, the location will come from the orientation if it is set (vertical colorbars on the right, horizontal ones at the bottom), or default to 'right' if orientation is unset.
orientationNone or {'vertical', 'horizontal'}

The orientation of the colorbar. It is preferable to set the location of the colorbar, as that also determines the orientation; passing incompatible values for location and orientation raises an exception.
fractionfloat, default: 0.15

Fraction of original axes to use for colorbar.
shrinkfloat, default: 1.0

Fraction by which to multiply the size of the colorbar.
aspectfloat, default: 20

Ratio of long to short dimensions.    Returns

caxSubplotBase

The child axes.
kwdict

The reduced keyword dictionary to be passed when creating the colorbar instance.    Other Parameters

padfloat, default: 0.05 if vertical, 0.15 if horizontal

Fraction of original axes between colorbar and new image axes.
anchor(float, float), optional

The anchor point of the colorbar axes. Defaults to (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal.
panchor(float, float), or False, optional

The anchor point of the colorbar parent axes. If False, the parent axes' anchor will be unchanged. Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal.


matplotlib.colormaps[source]

Container for colormaps that are known to Matplotlib by name.  Experimental While we expect the API to be final, we formally mark it as experimental for 3.5 because we want to keep the option to still adapt the API for 3.6 should the need arise.  The universal registry instance is matplotlib.colormaps. There should be no need for users to instantiate ColormapRegistry themselves. Read access uses a dict-like interface mapping names to Colormaps: import matplotlib as mpl
cmap = mpl.colormaps['viridis']
 Returned Colormaps are copies, so that their modification does not change the global definition of the colormap. Additional colormaps can be added via ColormapRegistry.register: mpl.colormaps.register(my_colormap)


matplotlib.colors  Note The Color tutorials and examples demonstrate how to set colors and colormaps. You may want to read those instead.  A module for converting numbers or color arguments to RGB or RGBA. RGB and RGBA are sequences of, respectively, 3 or 4 floats in the range 0-1. This module includes functions and classes for color specification conversions, and for mapping numbers to colors in a 1-D array of colors called a colormap. Mapping data onto colors using a colormap typically involves two steps: a data array is first mapped onto the range 0-1 using a subclass of Normalize, then this number is mapped to a color using a subclass of Colormap. Two subclasses of Colormap provided here: LinearSegmentedColormap, which uses piecewise-linear interpolation to define colormaps, and ListedColormap, which makes a colormap from a list of colors.  See also Creating Colormaps in Matplotlib for examples of how to make colormaps and Choosing Colormaps in Matplotlib for a list of built-in colormaps. Colormap Normalization for more details about data normalization More colormaps are available at palettable.  The module also provides functions for checking whether an object can be interpreted as a color (is_color_like), for converting such an object to an RGBA tuple (to_rgba) or to an HTML-like hex string in the "#rrggbb" format (to_hex), and a sequence of colors to an (n, 4) RGBA array (to_rgba_array). Caching is used for efficiency. Colors that Matplotlib recognizes are listed at Specifying Colors.  Classes
BoundaryNorm(boundaries, ncolors[, clip, extend]) Generate a colormap index based on discrete intervals.
Colormap(name[, N]) Baseclass for all scalar to RGBA mappings.
CenteredNorm([vcenter, halfrange, clip]) Normalize symmetrical data around a center (0 by default).
LightSource([azdeg, altdeg, hsv_min_val, ...]) Create a light source coming from the specified azimuth and elevation.
LinearSegmentedColormap(name, segmentdata[, ...]) Colormap objects based on lookup tables using linear segments.
ListedColormap(colors[, name, N]) Colormap object generated from a list of colors.
LogNorm([vmin, vmax, clip]) Normalize a given value to the 0-1 range on a log scale.
NoNorm([vmin, vmax, clip]) Dummy replacement for Normalize, for the case where we want to use indices directly in a ScalarMappable.
Normalize([vmin, vmax, clip]) A class which, when called, linearly normalizes data into the [0.0, 1.0] interval.
PowerNorm(gamma[, vmin, vmax, clip]) Linearly map a given value to the 0-1 range and then apply a power-law normalization over that range.
SymLogNorm(linthresh[, linscale, vmin, ...]) The symmetrical logarithmic scale is logarithmic in both the positive and negative directions from the origin.
TwoSlopeNorm(vcenter[, vmin, vmax]) Normalize data with a set center.
FuncNorm(functions[, vmin, vmax, clip]) Arbitrary normalization using functions for the forward and inverse.     Functions
from_levels_and_colors(levels, colors[, extend]) A helper routine to generate a cmap and a norm instance which behave similar to contourf's levels and colors arguments.
hsv_to_rgb(hsv) Convert hsv values to rgb.
rgb_to_hsv(arr) Convert float rgb values (in the range [0, 1]), in a numpy array to hsv values.
to_hex(c[, keep_alpha]) Convert c to a hex color.
to_rgb(c) Convert c to an RGB color, silently dropping the alpha channel.
to_rgba(c[, alpha]) Convert c to an RGBA color.
to_rgba_array(c[, alpha]) Convert c to a (n, 4) array of RGBA colors.
is_color_like(c) Return whether c can be interpreted as an RGB(A) color.
same_color(c1, c2) Return whether the colors c1 and c2 are the same.
get_named_colors_mapping() Return the global mapping of names to named colors.
make_norm_from_scale(scale_cls[, ...]) Decorator for building a Normalize subclass from a ScaleBase subclass.


matplotlib.colors.BoundaryNorm   classmatplotlib.colors.BoundaryNorm(boundaries, ncolors, clip=False, *, extend='neither')[source]

Bases: matplotlib.colors.Normalize Generate a colormap index based on discrete intervals. Unlike Normalize or LogNorm, BoundaryNorm maps values to integers instead of to the interval 0-1. Mapping to the 0-1 interval could have been done via piece-wise linear interpolation, but using integers seems simpler, and reduces the number of conversions back and forth between integer and floating point.  Parameters

boundariesarray-like

Monotonically increasing sequence of at least 2 boundaries.
ncolorsint

Number of colors in the colormap to be used.
clipbool, optional

If clip is True, out of range values are mapped to 0 if they are below boundaries[0] or mapped to ncolors - 1 if they are above boundaries[-1]. If clip is False, out of range values are mapped to -1 if they are below boundaries[0] or mapped to ncolors if they are above boundaries[-1]. These are then converted to valid indices by Colormap.__call__.
extend{'neither', 'both', 'min', 'max'}, default: 'neither'

Extend the number of bins to include one or both of the regions beyond the boundaries. For example, if extend is 'min', then the color to which the region between the first pair of boundaries is mapped will be distinct from the first color in the colormap, and by default a Colorbar will be drawn with the triangle extension on the left or lower end.    Returns
 int16 scalar or array
   Notes boundaries defines the edges of bins, and data falling within a bin is mapped to the color with the same index. If the number of bins, including any extensions, is less than ncolors, the color index is chosen by linear interpolation, mapping the [0, nbins - 1] range onto the [0, ncolors - 1] range.   __call__(value, clip=None)[source]

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.  Parameters
 value

Data to normalize.
clipbool

If None, defaults to self.clip (which defaults to False).     Notes If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
   inverse(value)[source]

 Raises
 ValueError

BoundaryNorm is not invertible, so calling this method will always raise an error

  Examples using matplotlib.colors.BoundaryNorm

   Multicolored lines

   Creating annotated heatmaps

   Image Masked

   pcolormesh

   Left ventricle bullseye

   Colormap Normalizations

   Customized Colorbars Tutorial

   Colormap Normalization


__call__(value, clip=None)[source]

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.  Parameters
 value

Data to normalize.
clipbool

If None, defaults to self.clip (which defaults to False).     Notes If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).


inverse(value)[source]

 Raises
 ValueError

BoundaryNorm is not invertible, so calling this method will always raise an error


matplotlib.colors.CenteredNorm   classmatplotlib.colors.CenteredNorm(vcenter=0, halfrange=None, clip=False)[source]

Bases: matplotlib.colors.Normalize Normalize symmetrical data around a center (0 by default). Unlike TwoSlopeNorm, CenteredNorm applies an equal rate of change around the center. Useful when mapping symmetrical data around a conceptual center e.g., data that range from -2 to 4, with 0 as the midpoint, and with equal rates of change around that midpoint.  Parameters

vcenterfloat, default: 0

The data value that defines 0.5 in the normalization.
halfrangefloat, optional

The range of data values that defines a range of 0.5 in the normalization, so that vcenter - halfrange is 0.0 and vcenter + halfrange is 1.0 in the normalization. Defaults to the largest absolute difference to vcenter for the values in the dataset.     Examples This maps data values -2 to 0.25, 0 to 0.5, and 4 to 1.0 (assuming equal rates of change above and below 0.0): >>> import matplotlib.colors as mcolors
>>> norm = mcolors.CenteredNorm(halfrange=4.0)
>>> data = [-2., 0., 4.]
>>> norm(data)
array([0.25, 0.5 , 1.  ])
   __call__(value, clip=None)[source]

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.  Parameters
 value

Data to normalize.
clipbool

If None, defaults to self.clip (which defaults to False).     Notes If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
   autoscale(A)[source]

Set halfrange to max(abs(A-vcenter)), then set vmin and vmax.
   autoscale_None(A)[source]

Set vmin and vmax.
   propertyhalfrange

   propertyvcenter

  Examples using matplotlib.colors.CenteredNorm

   Colormap Normalization


autoscale(A)[source]

Set halfrange to max(abs(A-vcenter)), then set vmin and vmax.


autoscale_None(A)[source]

Set vmin and vmax.


matplotlib.colors.Colormap   classmatplotlib.colors.Colormap(name, N=256)[source]

Bases: object Baseclass for all scalar to RGBA mappings. Typically, Colormap instances are used to convert data values (floats) from the interval [0, 1] to the RGBA color that the respective Colormap represents. For scaling of data into the [0, 1] interval see matplotlib.colors.Normalize. Subclasses of matplotlib.cm.ScalarMappable make heavy use of this data -> normalize -> map-to-color processing chain.  Parameters

namestr

The name of the colormap.
Nint

The number of rgb quantization levels.       __call__(X, alpha=None, bytes=False)[source]

 Parameters

Xfloat or int, ndarray or scalar

The data value(s) to convert to RGBA. For floats, X should be in the interval [0.0, 1.0] to return the RGBA values X*100 percent along the Colormap line. For integers, X should be in the interval [0, Colormap.N) to return RGBA values indexed from the Colormap with index X.
alphafloat or array-like or None

Alpha must be a scalar between 0 and 1, a sequence of such floats with shape matching X, or None.
bytesbool

If False (default), the returned RGBA values will be floats in the interval [0, 1] otherwise they will be uint8s in the interval [0, 255].    Returns
 Tuple of RGBA values if X is scalar, otherwise an array of
RGBA values with a shape of X.shape + (4, ).

   colorbar_extend

When this colormap exists on a scalar mappable and colorbar_extend is not False, colorbar creation will pick up colorbar_extend as the default value for the extend keyword in the matplotlib.colorbar.Colorbar constructor.
   copy()[source]

Return a copy of the colormap.
   get_bad()[source]

Get the color for masked values.
   get_over()[source]

Get the color for high out-of-range values.
   get_under()[source]

Get the color for low out-of-range values.
   is_gray()[source]

Return whether the colormap is grayscale.
   reversed(name=None)[source]

Return a reversed instance of the Colormap.  Note This function is not implemented for base class.   Parameters

namestr, optional

The name for the reversed colormap. If it's None the name will be the name of the parent colormap + "_r".      See also  LinearSegmentedColormap.reversed
ListedColormap.reversed

   set_bad(color='k', alpha=None)[source]

Set the color for masked values.
   set_extremes(*, bad=None, under=None, over=None)[source]

Set the colors for masked (bad) values and, when norm.clip =
False, low (under) and high (over) out-of-range values.
   set_over(color='k', alpha=None)[source]

Set the color for high out-of-range values.
   set_under(color='k', alpha=None)[source]

Set the color for low out-of-range values.
   with_extremes(*, bad=None, under=None, over=None)[source]

Return a copy of the colormap, for which the colors for masked (bad) values and, when norm.clip = False, low (under) and high (over) out-of-range values, have been set accordingly.

  Examples using matplotlib.colors.Colormap

   Multicolored lines

   Creating a colormap from a list of colors

   Left ventricle bullseye

   Customized Colorbars Tutorial

   Creating Colormaps in Matplotlib


__call__(X, alpha=None, bytes=False)[source]

 Parameters

Xfloat or int, ndarray or scalar

The data value(s) to convert to RGBA. For floats, X should be in the interval [0.0, 1.0] to return the RGBA values X*100 percent along the Colormap line. For integers, X should be in the interval [0, Colormap.N) to return RGBA values indexed from the Colormap with index X.
alphafloat or array-like or None

Alpha must be a scalar between 0 and 1, a sequence of such floats with shape matching X, or None.
bytesbool

If False (default), the returned RGBA values will be floats in the interval [0, 1] otherwise they will be uint8s in the interval [0, 255].    Returns
 Tuple of RGBA values if X is scalar, otherwise an array of
RGBA values with a shape of X.shape + (4, ).


colorbar_extend

When this colormap exists on a scalar mappable and colorbar_extend is not False, colorbar creation will pick up colorbar_extend as the default value for the extend keyword in the matplotlib.colorbar.Colorbar constructor.


copy()[source]

Return a copy of the colormap.


get_bad()[source]

Get the color for masked values.


get_over()[source]

Get the color for high out-of-range values.


get_under()[source]

Get the color for low out-of-range values.


is_gray()[source]

Return whether the colormap is grayscale.


reversed(name=None)[source]

Return a reversed instance of the Colormap.  Note This function is not implemented for base class.   Parameters

namestr, optional

The name for the reversed colormap. If it's None the name will be the name of the parent colormap + "_r".      See also  LinearSegmentedColormap.reversed
ListedColormap.reversed


set_bad(color='k', alpha=None)[source]

Set the color for masked values.


set_extremes(*, bad=None, under=None, over=None)[source]

Set the colors for masked (bad) values and, when norm.clip =
False, low (under) and high (over) out-of-range values.


set_over(color='k', alpha=None)[source]

Set the color for high out-of-range values.


set_under(color='k', alpha=None)[source]

Set the color for low out-of-range values.


with_extremes(*, bad=None, under=None, over=None)[source]

Return a copy of the colormap, for which the colors for masked (bad) values and, when norm.clip = False, low (under) and high (over) out-of-range values, have been set accordingly.


matplotlib.colors.from_levels_and_colors   matplotlib.colors.from_levels_and_colors(levels, colors, extend='neither')[source]

A helper routine to generate a cmap and a norm instance which behave similar to contourf's levels and colors arguments.  Parameters

levelssequence of numbers

The quantization levels used to construct the BoundaryNorm. Value v is quantized to level i if lev[i] <= v < lev[i+1].
colorssequence of colors

The fill color to use for each level. If extend is "neither" there must be n_level - 1 colors. For an extend of "min" or "max" add one extra color, and for an extend of "both" add two colors.
extend{'neither', 'min', 'max', 'both'}, optional

The behaviour when a value falls out of range of the given levels. See contourf for details.    Returns

cmapNormalize

normColormap


matplotlib.colors.FuncNorm   classmatplotlib.colors.FuncNorm(functions, vmin=None, vmax=None, clip=False)[source]

Bases: matplotlib.colors.FuncNorm Arbitrary normalization using functions for the forward and inverse.  Parameters

functions(callable, callable)

two-tuple of the forward and inverse functions for the normalization. The forward function must be monotonic. Both functions must have the signature def forward(values: array-like) -> array-like

vmin, vmaxfloat or None

If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).
clipbool, default: False

If True values falling outside the range [vmin, vmax], are mapped to 0 or 1, whichever is closer, and masked values are set to 1. If False masked values remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in a colormap, so it is likely to lead to surprises; therefore the default is clip=False.      Parameters

vmin, vmaxfloat or None

If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).
clipbool, default: False

If True values falling outside the range [vmin, vmax], are mapped to 0 or 1, whichever is closer, and masked values are set to 1. If False masked values remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in a colormap, so it is likely to lead to surprises; therefore the default is clip=False.     Notes Returns 0 if vmin == vmax.   __call__(value, clip=None)[source]

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.  Parameters
 value

Data to normalize.
clipbool

If None, defaults to self.clip (which defaults to False).     Notes If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
   inverse(value)[source]

  Examples using matplotlib.colors.FuncNorm

   Colormap Normalization


__call__(value, clip=None)[source]

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.  Parameters
 value

Data to normalize.
clipbool

If None, defaults to self.clip (which defaults to False).     Notes If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).


matplotlib.colors.get_named_colors_mapping   matplotlib.colors.get_named_colors_mapping()[source]

Return the global mapping of names to named colors.


matplotlib.colors.hsv_to_rgb   matplotlib.colors.hsv_to_rgb(hsv)[source]

Convert hsv values to rgb.  Parameters

hsv(..., 3) array-like

All values assumed to be in range [0, 1]    Returns
 (..., 3) ndarray

Colors converted to RGB values in range [0, 1]
  Examples using matplotlib.colors.hsv_to_rgb

   3D voxel / volumetric plot with cylindrical coordinates


matplotlib.colors.is_color_like   matplotlib.colors.is_color_like(c)[source]

Return whether c can be interpreted as an RGB(A) color.


matplotlib.colors.LightSource   classmatplotlib.colors.LightSource(azdeg=315, altdeg=45, hsv_min_val=0, hsv_max_val=1, hsv_min_sat=1, hsv_max_sat=0)[source]

Bases: object Create a light source coming from the specified azimuth and elevation. Angles are in degrees, with the azimuth measured clockwise from north and elevation up from the zero plane of the surface. shade is used to produce "shaded" rgb values for a data array. shade_rgb can be used to combine an rgb image with an elevation map. hillshade produces an illumination map of a surface. Specify the azimuth (measured clockwise from south) and altitude (measured up from the plane of the surface) of the light source in degrees.  Parameters

azdegfloat, default: 315 degrees (from the northwest)

The azimuth (0-360, degrees clockwise from North) of the light source.
altdegfloat, default: 45 degrees

The altitude (0-90, degrees up from horizontal) of the light source.     Notes For backwards compatibility, the parameters hsv_min_val, hsv_max_val, hsv_min_sat, and hsv_max_sat may be supplied at initialization as well. However, these parameters will only be used if "blend_mode='hsv'" is passed into shade or shade_rgb. See the documentation for blend_hsv for more details.   blend_hsv(rgb, intensity, hsv_max_sat=None, hsv_max_val=None, hsv_min_val=None, hsv_min_sat=None)[source]

Take the input data array, convert to HSV values in the given colormap, then adjust those color values to give the impression of a shaded relief map with a specified light source. RGBA values are returned, which can then be used to plot the shaded image with imshow. The color of the resulting image will be darkened by moving the (s, v) values (in hsv colorspace) toward (hsv_min_sat, hsv_min_val) in the shaded regions, or lightened by sliding (s, v) toward (hsv_max_sat, hsv_max_val) in regions that are illuminated. The default extremes are chose so that completely shaded points are nearly black (s = 1, v = 0) and completely illuminated points are nearly white (s = 0, v = 1).  Parameters

rgbndarray

An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
intensityndarray

An MxNx1 array of floats ranging from 0 to 1 (grayscale image).
hsv_max_satnumber, default: 1

The maximum saturation value that the intensity map can shift the output image to.
hsv_min_satnumber, optional

The minimum saturation value that the intensity map can shift the output image to. Defaults to 0.
hsv_max_valnumber, optional

The maximum value ("v" in "hsv") that the intensity map can shift the output image to. Defaults to 1.
hsv_min_valnumber, optional

The minimum value ("v" in "hsv") that the intensity map can shift the output image to. Defaults to 0.    Returns
 ndarray

An MxNx3 RGB array representing the combined images.
   blend_overlay(rgb, intensity)[source]

Combine an rgb image with an intensity map using "overlay" blending.  Parameters

rgbndarray

An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
intensityndarray

An MxNx1 array of floats ranging from 0 to 1 (grayscale image).    Returns
 ndarray

An MxNx3 RGB array representing the combined images.
   blend_soft_light(rgb, intensity)[source]

Combine an rgb image with an intensity map using "soft light" blending, using the "pegtop" formula.  Parameters

rgbndarray

An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
intensityndarray

An MxNx1 array of floats ranging from 0 to 1 (grayscale image).    Returns
 ndarray

An MxNx3 RGB array representing the combined images.
   propertydirection

The unit vector direction towards the light source.
   hillshade(elevation, vert_exag=1, dx=1, dy=1, fraction=1.0)[source]

Calculate the illumination intensity for a surface using the defined azimuth and elevation for the light source. This computes the normal vectors for the surface, and then passes them on to shade_normals  Parameters

elevation2D array-like

The height values used to generate an illumination map
vert_exagnumber, optional

The amount to exaggerate the elevation values by when calculating illumination. This can be used either to correct for differences in units between the x-y coordinate system and the elevation coordinate system (e.g. decimal degrees vs. meters) or to exaggerate or de-emphasize topographic effects.
dxnumber, optional

The x-spacing (columns) of the input elevation grid.
dynumber, optional

The y-spacing (rows) of the input elevation grid.
fractionnumber, optional

Increases or decreases the contrast of the hillshade. Values greater than one will cause intermediate values to move closer to full illumination or shadow (and clipping any values that move beyond 0 or 1). Note that this is not visually or mathematically the same as vertical exaggeration.    Returns
 ndarray

A 2D array of illumination values between 0-1, where 0 is completely in shadow and 1 is completely illuminated.
   shade(data, cmap, norm=None, blend_mode='overlay', vmin=None, vmax=None, vert_exag=1, dx=1, dy=1, fraction=1, **kwargs)[source]

Combine colormapped data values with an illumination intensity map (a.k.a. "hillshade") of the values.  Parameters

data2D array-like

The height values used to generate a shaded map.
cmapColormap

The colormap used to color the data array. Note that this must be a Colormap instance. For example, rather than passing in cmap='gist_earth', use cmap=plt.get_cmap('gist_earth') instead.
normNormalize instance, optional

The normalization used to scale values before colormapping. If None, the input will be linearly scaled between its min and max.
blend_mode{'hsv', 'overlay', 'soft'} or callable, optional

The type of blending used to combine the colormapped data values with the illumination intensity. Default is "overlay". Note that for most topographic surfaces, "overlay" or "soft" appear more visually realistic. If a user-defined function is supplied, it is expected to combine an MxNx3 RGB array of floats (ranging 0 to 1) with an MxNx1 hillshade array (also 0 to 1). (Call signature func(rgb, illum, **kwargs)) Additional kwargs supplied to this function will be passed on to the blend_mode function.
vminfloat or None, optional

The minimum value used in colormapping data. If None the minimum value in data is used. If norm is specified, then this argument will be ignored.
vmaxfloat or None, optional

The maximum value used in colormapping data. If None the maximum value in data is used. If norm is specified, then this argument will be ignored.
vert_exagnumber, optional

The amount to exaggerate the elevation values by when calculating illumination. This can be used either to correct for differences in units between the x-y coordinate system and the elevation coordinate system (e.g. decimal degrees vs. meters) or to exaggerate or de-emphasize topography.
dxnumber, optional

The x-spacing (columns) of the input elevation grid.
dynumber, optional

The y-spacing (rows) of the input elevation grid.
fractionnumber, optional

Increases or decreases the contrast of the hillshade. Values greater than one will cause intermediate values to move closer to full illumination or shadow (and clipping any values that move beyond 0 or 1). Note that this is not visually or mathematically the same as vertical exaggeration.  Additional kwargs are passed on to the *blend_mode* function.
  Returns
 ndarray

An MxNx4 array of floats ranging between 0-1.
   shade_normals(normals, fraction=1.0)[source]

Calculate the illumination intensity for the normal vectors of a surface using the defined azimuth and elevation for the light source. Imagine an artificial sun placed at infinity in some azimuth and elevation position illuminating our surface. The parts of the surface that slope toward the sun should brighten while those sides facing away should become darker.  Parameters

fractionnumber, optional

Increases or decreases the contrast of the hillshade. Values greater than one will cause intermediate values to move closer to full illumination or shadow (and clipping any values that move beyond 0 or 1). Note that this is not visually or mathematically the same as vertical exaggeration.    Returns
 ndarray

A 2D array of illumination values between 0-1, where 0 is completely in shadow and 1 is completely illuminated.
   shade_rgb(rgb, elevation, fraction=1.0, blend_mode='hsv', vert_exag=1, dx=1, dy=1, **kwargs)[source]

Use this light source to adjust the colors of the rgb input array to give the impression of a shaded relief map with the given elevation.  Parameters

rgbarray-like

An (M, N, 3) RGB array, assumed to be in the range of 0 to 1.
elevationarray-like

An (M, N) array of the height values used to generate a shaded map.
fractionnumber

Increases or decreases the contrast of the hillshade. Values greater than one will cause intermediate values to move closer to full illumination or shadow (and clipping any values that move beyond 0 or 1). Note that this is not visually or mathematically the same as vertical exaggeration.
blend_mode{'hsv', 'overlay', 'soft'} or callable, optional

The type of blending used to combine the colormapped data values with the illumination intensity. For backwards compatibility, this defaults to "hsv". Note that for most topographic surfaces, "overlay" or "soft" appear more visually realistic. If a user-defined function is supplied, it is expected to combine an MxNx3 RGB array of floats (ranging 0 to 1) with an MxNx1 hillshade array (also 0 to 1). (Call signature func(rgb, illum, **kwargs)) Additional kwargs supplied to this function will be passed on to the blend_mode function.
vert_exagnumber, optional

The amount to exaggerate the elevation values by when calculating illumination. This can be used either to correct for differences in units between the x-y coordinate system and the elevation coordinate system (e.g. decimal degrees vs. meters) or to exaggerate or de-emphasize topography.
dxnumber, optional

The x-spacing (columns) of the input elevation grid.
dynumber, optional

The y-spacing (rows) of the input elevation grid.  Additional kwargs are passed on to the *blend_mode* function.
  Returns
 ndarray

An (m, n, 3) array of floats ranging between 0-1.

  Examples using matplotlib.colors.LightSource

   Shading example

   Shaded & power normalized rendering

   Frontpage 3D example

   AGG filter

   Custom hillshading in a 3D surface plot

   Hillshading

   Topographic hillshading


blend_hsv(rgb, intensity, hsv_max_sat=None, hsv_max_val=None, hsv_min_val=None, hsv_min_sat=None)[source]

Take the input data array, convert to HSV values in the given colormap, then adjust those color values to give the impression of a shaded relief map with a specified light source. RGBA values are returned, which can then be used to plot the shaded image with imshow. The color of the resulting image will be darkened by moving the (s, v) values (in hsv colorspace) toward (hsv_min_sat, hsv_min_val) in the shaded regions, or lightened by sliding (s, v) toward (hsv_max_sat, hsv_max_val) in regions that are illuminated. The default extremes are chose so that completely shaded points are nearly black (s = 1, v = 0) and completely illuminated points are nearly white (s = 0, v = 1).  Parameters

rgbndarray

An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
intensityndarray

An MxNx1 array of floats ranging from 0 to 1 (grayscale image).
hsv_max_satnumber, default: 1

The maximum saturation value that the intensity map can shift the output image to.
hsv_min_satnumber, optional

The minimum saturation value that the intensity map can shift the output image to. Defaults to 0.
hsv_max_valnumber, optional

The maximum value ("v" in "hsv") that the intensity map can shift the output image to. Defaults to 1.
hsv_min_valnumber, optional

The minimum value ("v" in "hsv") that the intensity map can shift the output image to. Defaults to 0.    Returns
 ndarray

An MxNx3 RGB array representing the combined images.


blend_overlay(rgb, intensity)[source]

Combine an rgb image with an intensity map using "overlay" blending.  Parameters

rgbndarray

An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
intensityndarray

An MxNx1 array of floats ranging from 0 to 1 (grayscale image).    Returns
 ndarray

An MxNx3 RGB array representing the combined images.


blend_soft_light(rgb, intensity)[source]

Combine an rgb image with an intensity map using "soft light" blending, using the "pegtop" formula.  Parameters

rgbndarray

An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
intensityndarray

An MxNx1 array of floats ranging from 0 to 1 (grayscale image).    Returns
 ndarray

An MxNx3 RGB array representing the combined images.


hillshade(elevation, vert_exag=1, dx=1, dy=1, fraction=1.0)[source]

Calculate the illumination intensity for a surface using the defined azimuth and elevation for the light source. This computes the normal vectors for the surface, and then passes them on to shade_normals  Parameters

elevation2D array-like

The height values used to generate an illumination map
vert_exagnumber, optional

The amount to exaggerate the elevation values by when calculating illumination. This can be used either to correct for differences in units between the x-y coordinate system and the elevation coordinate system (e.g. decimal degrees vs. meters) or to exaggerate or de-emphasize topographic effects.
dxnumber, optional

The x-spacing (columns) of the input elevation grid.
dynumber, optional

The y-spacing (rows) of the input elevation grid.
fractionnumber, optional

Increases or decreases the contrast of the hillshade. Values greater than one will cause intermediate values to move closer to full illumination or shadow (and clipping any values that move beyond 0 or 1). Note that this is not visually or mathematically the same as vertical exaggeration.    Returns
 ndarray

A 2D array of illumination values between 0-1, where 0 is completely in shadow and 1 is completely illuminated.


shade(data, cmap, norm=None, blend_mode='overlay', vmin=None, vmax=None, vert_exag=1, dx=1, dy=1, fraction=1, **kwargs)[source]

Combine colormapped data values with an illumination intensity map (a.k.a. "hillshade") of the values.  Parameters

data2D array-like

The height values used to generate a shaded map.
cmapColormap

The colormap used to color the data array. Note that this must be a Colormap instance. For example, rather than passing in cmap='gist_earth', use cmap=plt.get_cmap('gist_earth') instead.
normNormalize instance, optional

The normalization used to scale values before colormapping. If None, the input will be linearly scaled between its min and max.
blend_mode{'hsv', 'overlay', 'soft'} or callable, optional

The type of blending used to combine the colormapped data values with the illumination intensity. Default is "overlay". Note that for most topographic surfaces, "overlay" or "soft" appear more visually realistic. If a user-defined function is supplied, it is expected to combine an MxNx3 RGB array of floats (ranging 0 to 1) with an MxNx1 hillshade array (also 0 to 1). (Call signature func(rgb, illum, **kwargs)) Additional kwargs supplied to this function will be passed on to the blend_mode function.
vminfloat or None, optional

The minimum value used in colormapping data. If None the minimum value in data is used. If norm is specified, then this argument will be ignored.
vmaxfloat or None, optional

The maximum value used in colormapping data. If None the maximum value in data is used. If norm is specified, then this argument will be ignored.
vert_exagnumber, optional

The amount to exaggerate the elevation values by when calculating illumination. This can be used either to correct for differences in units between the x-y coordinate system and the elevation coordinate system (e.g. decimal degrees vs. meters) or to exaggerate or de-emphasize topography.
dxnumber, optional

The x-spacing (columns) of the input elevation grid.
dynumber, optional

The y-spacing (rows) of the input elevation grid.
fractionnumber, optional

Increases or decreases the contrast of the hillshade. Values greater than one will cause intermediate values to move closer to full illumination or shadow (and clipping any values that move beyond 0 or 1). Note that this is not visually or mathematically the same as vertical exaggeration.  Additional kwargs are passed on to the *blend_mode* function.
  Returns
 ndarray

An MxNx4 array of floats ranging between 0-1.


shade_normals(normals, fraction=1.0)[source]

Calculate the illumination intensity for the normal vectors of a surface using the defined azimuth and elevation for the light source. Imagine an artificial sun placed at infinity in some azimuth and elevation position illuminating our surface. The parts of the surface that slope toward the sun should brighten while those sides facing away should become darker.  Parameters

fractionnumber, optional

Increases or decreases the contrast of the hillshade. Values greater than one will cause intermediate values to move closer to full illumination or shadow (and clipping any values that move beyond 0 or 1). Note that this is not visually or mathematically the same as vertical exaggeration.    Returns
 ndarray

A 2D array of illumination values between 0-1, where 0 is completely in shadow and 1 is completely illuminated.


shade_rgb(rgb, elevation, fraction=1.0, blend_mode='hsv', vert_exag=1, dx=1, dy=1, **kwargs)[source]

Use this light source to adjust the colors of the rgb input array to give the impression of a shaded relief map with the given elevation.  Parameters

rgbarray-like

An (M, N, 3) RGB array, assumed to be in the range of 0 to 1.
elevationarray-like

An (M, N) array of the height values used to generate a shaded map.
fractionnumber

Increases or decreases the contrast of the hillshade. Values greater than one will cause intermediate values to move closer to full illumination or shadow (and clipping any values that move beyond 0 or 1). Note that this is not visually or mathematically the same as vertical exaggeration.
blend_mode{'hsv', 'overlay', 'soft'} or callable, optional

The type of blending used to combine the colormapped data values with the illumination intensity. For backwards compatibility, this defaults to "hsv". Note that for most topographic surfaces, "overlay" or "soft" appear more visually realistic. If a user-defined function is supplied, it is expected to combine an MxNx3 RGB array of floats (ranging 0 to 1) with an MxNx1 hillshade array (also 0 to 1). (Call signature func(rgb, illum, **kwargs)) Additional kwargs supplied to this function will be passed on to the blend_mode function.
vert_exagnumber, optional

The amount to exaggerate the elevation values by when calculating illumination. This can be used either to correct for differences in units between the x-y coordinate system and the elevation coordinate system (e.g. decimal degrees vs. meters) or to exaggerate or de-emphasize topography.
dxnumber, optional

The x-spacing (columns) of the input elevation grid.
dynumber, optional

The y-spacing (rows) of the input elevation grid.  Additional kwargs are passed on to the *blend_mode* function.
  Returns
 ndarray

An (m, n, 3) array of floats ranging between 0-1.


matplotlib.colors.LinearSegmentedColormap   classmatplotlib.colors.LinearSegmentedColormap(name, segmentdata, N=256, gamma=1.0)[source]

Bases: matplotlib.colors.Colormap Colormap objects based on lookup tables using linear segments. The lookup table is generated using linear interpolation for each primary color, with the 0-1 domain divided into any number of segments. Create colormap from linear mapping segments segmentdata argument is a dictionary with a red, green and blue entries. Each entry should be a list of x, y0, y1 tuples, forming rows in a table. Entries for alpha are optional. Example: suppose you want red to increase from 0 to 1 over the bottom half, green to do the same over the middle half, and blue over the top half. Then you would use: cdict = {'red':   [(0.0,  0.0, 0.0),
                   (0.5,  1.0, 1.0),
                   (1.0,  1.0, 1.0)],

         'green': [(0.0,  0.0, 0.0),
                   (0.25, 0.0, 0.0),
                   (0.75, 1.0, 1.0),
                   (1.0,  1.0, 1.0)],

         'blue':  [(0.0,  0.0, 0.0),
                   (0.5,  0.0, 0.0),
                   (1.0,  1.0, 1.0)]}
 Each row in the table for a given color is a sequence of x, y0, y1 tuples. In each sequence, x must increase monotonically from 0 to 1. For any input value z falling between x[i] and x[i+1], the output value of a given color will be linearly interpolated between y1[i] and y0[i+1]: row i:   x  y0  y1
               /
              /
row i+1: x  y0  y1
 Hence y0 in the first row and y1 in the last row are never used.  See also  LinearSegmentedColormap.from_list

Static method; factory function for generating a smoothly-varying LinearSegmentedColormap.      staticfrom_list(name, colors, N=256, gamma=1.0)[source]

Create a LinearSegmentedColormap from a list of colors.  Parameters

namestr

The name of the colormap.
colorsarray-like of colors or array-like of (value, color)

If only colors are given, they are equidistantly mapped from the range \([0, 1]\); i.e. 0 maps to colors[0] and 1 maps to colors[-1]. If (value, color) pairs are given, the mapping is from value to color. This can be used to divide the range unevenly.
Nint

The number of rgb quantization levels.
gammafloat

   reversed(name=None)[source]

Return a reversed instance of the Colormap.  Parameters

namestr, optional

The name for the reversed colormap. If it's None the name will be the name of the parent colormap + "_r".    Returns
 LinearSegmentedColormap

The reversed colormap.
   set_gamma(gamma)[source]

Set a new gamma value and regenerate colormap.

  Examples using matplotlib.colors.LinearSegmentedColormap

   Bar chart with gradients

   Scatter plots with a legend

   Contour Demo

   Contour Image

   Contourf Demo

   Contourf and log color scale

   Image Demo

   Image Masked

   Image Nonuniform

   Layer Images

   pcolormesh

   Shading example

   Axes box aspect

   Composing Custom Legends

   Using a text as a Path

   Creating a colormap from a list of colors

   Reference for Matplotlib artists

   Dolphins

   Demo CurveLinear Grid2

   Shaded & power normalized rendering

   Frontpage 3D example

   Manual Contour

   AGG filter

   Matplotlib logo

   Table Demo

   Demonstrates plotting contour (level) curves in 3D

   Demonstrates plotting contour (level) curves in 3D using the extend3d option

   Projecting contour profiles onto a graph

   Filled contours

   Projecting filled contour onto a graph

   Custom hillshading in a 3D surface plot

   3D plots as subplots

   3D surface (colormap)

   3D surface with polar coordinates

   Triangular 3D contour plot

   Triangular 3D filled contour plot

   More triangular 3D surfaces

   Hillshading

   Left ventricle bullseye

   MRI With EEG

   Topographic hillshading

   Dropped spines

   Colorbar Tick Labelling

   Customized Colorbars Tutorial

   Creating Colormaps in Matplotlib

   Colormap Normalization


staticfrom_list(name, colors, N=256, gamma=1.0)[source]

Create a LinearSegmentedColormap from a list of colors.  Parameters

namestr

The name of the colormap.
colorsarray-like of colors or array-like of (value, color)

If only colors are given, they are equidistantly mapped from the range \([0, 1]\); i.e. 0 maps to colors[0] and 1 maps to colors[-1]. If (value, color) pairs are given, the mapping is from value to color. This can be used to divide the range unevenly.
Nint

The number of rgb quantization levels.
gammafloat


reversed(name=None)[source]

Return a reversed instance of the Colormap.  Parameters

namestr, optional

The name for the reversed colormap. If it's None the name will be the name of the parent colormap + "_r".    Returns
 LinearSegmentedColormap

The reversed colormap.


set_gamma(gamma)[source]

Set a new gamma value and regenerate colormap.


matplotlib.colors.ListedColormap   classmatplotlib.colors.ListedColormap(colors, name='from_list', N=None)[source]

Bases: matplotlib.colors.Colormap Colormap object generated from a list of colors. This may be most useful when indexing directly into a colormap, but it can also be used to generate special colormaps for ordinary mapping.  Parameters

colorslist, array

List of Matplotlib color specifications, or an equivalent Nx3 or Nx4 floating point array (N rgb or rgba values).
namestr, optional

String to identify the colormap.
Nint, optional

Number of entries in the map. The default is None, in which case there is one colormap entry for each element in the list of colors. If N < len(colors)
 the list will be truncated at N. If N > len(colors)
 the list will be extended by repetition.      Parameters

namestr

The name of the colormap.
Nint

The number of rgb quantization levels.       reversed(name=None)[source]

Return a reversed instance of the Colormap.  Parameters

namestr, optional

The name for the reversed colormap. If it's None the name will be the name of the parent colormap + "_r".    Returns
 ListedColormap

A reversed instance of the colormap.

  Examples using matplotlib.colors.ListedColormap

   Multicolored lines

   Layer Images

   QuadMesh Demo

   Histograms

   Time Series Histogram

   Nested pie charts

   Bar chart on polar axis

   Left ventricle bullseye

   Customized Colorbars Tutorial

   Creating Colormaps in Matplotlib


reversed(name=None)[source]

Return a reversed instance of the Colormap.  Parameters

namestr, optional

The name for the reversed colormap. If it's None the name will be the name of the parent colormap + "_r".    Returns
 ListedColormap

A reversed instance of the colormap.


matplotlib.colors.LogNorm   classmatplotlib.colors.LogNorm(vmin=None, vmax=None, clip=False)[source]

Bases: matplotlib.colors.LogNorm Normalize a given value to the 0-1 range on a log scale.  Parameters

vmin, vmaxfloat or None

If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).
clipbool, default: False

If True values falling outside the range [vmin, vmax], are mapped to 0 or 1, whichever is closer, and masked values are set to 1. If False masked values remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in a colormap, so it is likely to lead to surprises; therefore the default is clip=False.     Notes Returns 0 if vmin == vmax.   __call__(value, clip=None)[source]

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.  Parameters
 value

Data to normalize.
clipbool

If None, defaults to self.clip (which defaults to False).     Notes If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
   inverse(value)[source]

  Examples using matplotlib.colors.LogNorm

   Pcolor Demo

   Histograms

   Time Series Histogram

   Colormap Normalizations

   Basic Usage

   Colormap Normalization


__call__(value, clip=None)[source]

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.  Parameters
 value

Data to normalize.
clipbool

If None, defaults to self.clip (which defaults to False).     Notes If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).


matplotlib.colors.make_norm_from_scale   matplotlib.colors.make_norm_from_scale(scale_cls, base_norm_cls=None, *, init=None)[source]

Decorator for building a Normalize subclass from a ScaleBase subclass. After @make_norm_from_scale(scale_cls)
class norm_cls(Normalize):
    ...
 norm_cls is filled with methods so that normalization computations are forwarded to scale_cls (i.e., scale_cls is the scale that would be used for the colorbar of a mappable normalized with norm_cls). If init is not passed, then the constructor signature of norm_cls will be norm_cls(vmin=None, vmax=None, clip=False); these three parameters will be forwarded to the base class (Normalize.__init__), and a scale_cls object will be initialized with no arguments (other than a dummy axis). If the scale_cls constructor takes additional parameters, then init should be passed to make_norm_from_scale. It is a callable which is only used for its signature. First, this signature will become the signature of norm_cls. Second, the norm_cls constructor will bind the parameters passed to it using this signature, extract the bound vmin, vmax, and clip values, pass those to Normalize.__init__, and forward the remaining bound values (including any defaults defined by the signature) to the scale_cls constructor.


matplotlib.colors.NoNorm   classmatplotlib.colors.NoNorm(vmin=None, vmax=None, clip=False)[source]

Bases: matplotlib.colors.Normalize Dummy replacement for Normalize, for the case where we want to use indices directly in a ScalarMappable.  Parameters

vmin, vmaxfloat or None

If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).
clipbool, default: False

If True values falling outside the range [vmin, vmax], are mapped to 0 or 1, whichever is closer, and masked values are set to 1. If False masked values remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in a colormap, so it is likely to lead to surprises; therefore the default is clip=False.     Notes Returns 0 if vmin == vmax.   __call__(value, clip=None)[source]

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.  Parameters
 value

Data to normalize.
clipbool

If None, defaults to self.clip (which defaults to False).     Notes If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
   inverse(value)[source]


matplotlib.colors.Normalize   classmatplotlib.colors.Normalize(vmin=None, vmax=None, clip=False)[source]

Bases: object A class which, when called, linearly normalizes data into the [0.0, 1.0] interval.  Parameters

vmin, vmaxfloat or None

If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).
clipbool, default: False

If True values falling outside the range [vmin, vmax], are mapped to 0 or 1, whichever is closer, and masked values are set to 1. If False masked values remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in a colormap, so it is likely to lead to surprises; therefore the default is clip=False.     Notes Returns 0 if vmin == vmax.   __call__(value, clip=None)[source]

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.  Parameters
 value

Data to normalize.
clipbool

If None, defaults to self.clip (which defaults to False).     Notes If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
   autoscale(A)[source]

Set vmin, vmax to min, max of A.
   autoscale_None(A)[source]

If vmin or vmax are not set, use the min/max of A to set them.
   propertyclip

   inverse(value)[source]

   staticprocess_value(value)[source]

Homogenize the input value for easy and efficient normalization. value can be a scalar or sequence.  Returns

resultmasked array

Masked array with the same shape as value.
is_scalarbool

Whether value is a scalar.     Notes Float dtypes are preserved; integer types with two bytes or smaller are converted to np.float32, and larger types are converted to np.float64. Preserving float32 when possible, and using in-place operations, greatly improves speed for large arrays.
   scaled()[source]

Return whether vmin and vmax are set.
   propertyvmax

   propertyvmin

  Examples using matplotlib.colors.Normalize

   Multicolored lines

   Contour Image

   Creating annotated heatmaps

   Image Masked

   Blend transparency with color in 2D images

   Multi Image

   Pcolor Demo

   pcolormesh

   Histograms

   Time Series Histogram

   Axes Grid2

   Shaded & power normalized rendering

   Frontpage contour example

   Exploring normalizations

   Hillshading

   Left ventricle bullseye

   Colormap Normalizations

   Colormap Normalizations Symlognorm

   Basic Usage

   Constrained Layout Guide

   Customized Colorbars Tutorial

   Colormap Normalization


autoscale(A)[source]

Set vmin, vmax to min, max of A.


autoscale_None(A)[source]

If vmin or vmax are not set, use the min/max of A to set them.


staticprocess_value(value)[source]

Homogenize the input value for easy and efficient normalization. value can be a scalar or sequence.  Returns

resultmasked array

Masked array with the same shape as value.
is_scalarbool

Whether value is a scalar.     Notes Float dtypes are preserved; integer types with two bytes or smaller are converted to np.float32, and larger types are converted to np.float64. Preserving float32 when possible, and using in-place operations, greatly improves speed for large arrays.


scaled()[source]

Return whether vmin and vmax are set.


matplotlib.colors.PowerNorm   classmatplotlib.colors.PowerNorm(gamma, vmin=None, vmax=None, clip=False)[source]

Bases: matplotlib.colors.Normalize Linearly map a given value to the 0-1 range and then apply a power-law normalization over that range.  Parameters

vmin, vmaxfloat or None

If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).
clipbool, default: False

If True values falling outside the range [vmin, vmax], are mapped to 0 or 1, whichever is closer, and masked values are set to 1. If False masked values remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in a colormap, so it is likely to lead to surprises; therefore the default is clip=False.     Notes Returns 0 if vmin == vmax.   __call__(value, clip=None)[source]

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.  Parameters
 value

Data to normalize.
clipbool

If None, defaults to self.clip (which defaults to False).     Notes If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
   inverse(value)[source]

  Examples using matplotlib.colors.PowerNorm

   Shaded & power normalized rendering

   Exploring normalizations

   Colormap Normalizations

   Colormap Normalization


matplotlib.colors.rgb_to_hsv   matplotlib.colors.rgb_to_hsv(arr)[source]

Convert float rgb values (in the range [0, 1]), in a numpy array to hsv values.  Parameters

arr(..., 3) array-like

All values must be in the range [0, 1]    Returns
 (..., 3) ndarray

Colors converted to hsv values in range [0, 1]
  Examples using matplotlib.colors.rgb_to_hsv

   List of named colors


matplotlib.colors.same_color   matplotlib.colors.same_color(c1, c2)[source]

Return whether the colors c1 and c2 are the same. c1, c2 can be single colors or lists/arrays of colors.


matplotlib.colors.SymLogNorm   classmatplotlib.colors.SymLogNorm(linthresh, linscale=1.0, vmin=None, vmax=None, clip=False, *, base=10)[source]

Bases: matplotlib.colors.SymLogNorm The symmetrical logarithmic scale is logarithmic in both the positive and negative directions from the origin. Since the values close to zero tend toward infinity, there is a need to have a range around zero that is linear. The parameter linthresh allows the user to specify the size of this range (-linthresh, linthresh).  Parameters

linthreshfloat

The range within which the plot is linear (to avoid having the plot go to infinity around zero).
linscalefloat, default: 1

This allows the linear range (-linthresh to linthresh) to be stretched relative to the logarithmic range. Its value is the number of decades to use for each half of the linear range. For example, when linscale == 1.0 (the default), the space used for the positive and negative halves of the linear range will be equal to one decade in the logarithmic range.
basefloat, default: 10

    Parameters

vmin, vmaxfloat or None

If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).
clipbool, default: False

If True values falling outside the range [vmin, vmax], are mapped to 0 or 1, whichever is closer, and masked values are set to 1. If False masked values remain masked. Clipping silently defeats the purpose of setting the over, under, and masked colors in a colormap, so it is likely to lead to surprises; therefore the default is clip=False.     Notes Returns 0 if vmin == vmax.   __call__(value, clip=None)[source]

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.  Parameters
 value

Data to normalize.
clipbool

If None, defaults to self.clip (which defaults to False).     Notes If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
   inverse(value)[source]

  Examples using matplotlib.colors.SymLogNorm

   Colormap Normalizations

   Colormap Normalizations Symlognorm

   Colormap Normalization


matplotlib.colors.to_hex   matplotlib.colors.to_hex(c, keep_alpha=False)[source]

Convert c to a hex color.  Parameters

ccolor or numpy.ma.masked

keep_alpha: bool, default: False

If False, use the #rrggbb format, otherwise use #rrggbbaa.    Returns
 str

#rrggbb or #rrggbbaa hex color string


matplotlib.colors.to_rgb   matplotlib.colors.to_rgb(c)[source]

Convert c to an RGB color, silently dropping the alpha channel.
  Examples using matplotlib.colors.to_rgb

   List of named colors


matplotlib.colors.to_rgba   matplotlib.colors.to_rgba(c, alpha=None)[source]

Convert c to an RGBA color.  Parameters

cMatplotlib color or np.ma.masked

alphafloat, optional

If alpha is given, force the alpha value of the returned RGBA tuple to alpha. If None, the alpha value from c is used. If c does not have an alpha channel, then alpha defaults to 1. alpha is ignored for the color value "none" (case-insensitive), which always maps to (0, 0, 0, 0).    Returns
 tuple

Tuple of floats (r, g, b, a), where each channel (red, green, blue, alpha) can assume values between 0 and 1.
  Examples using matplotlib.colors.to_rgba

   Line, Poly and RegularPoly Collection with autoscaling

   Line Collection

   Lasso Demo

   Ribbon Box


matplotlib.colors.to_rgba_array   matplotlib.colors.to_rgba_array(c, alpha=None)[source]

Convert c to a (n, 4) array of RGBA colors.  Parameters

cMatplotlib color or array of colors

If c is a masked array, an ndarray is returned with a (0, 0, 0, 0) row for each masked value or row in c.
alphafloat or sequence of floats, optional

If alpha is given, force the alpha value of the returned RGBA tuple to alpha. If None, the alpha value from c is used. If c does not have an alpha channel, then alpha defaults to 1. alpha is ignored for the color value "none" (case-insensitive), which always maps to (0, 0, 0, 0). If alpha is a sequence and c is a single color, c will be repeated to match the length of alpha.    Returns
 array

(n, 4) array of RGBA colors, where each channel (red, green, blue, alpha) can assume values between 0 and 1.
  Examples using matplotlib.colors.to_rgba_array

   Specifying Colors


matplotlib.colors.TwoSlopeNorm   classmatplotlib.colors.TwoSlopeNorm(vcenter, vmin=None, vmax=None)[source]

Bases: matplotlib.colors.Normalize Normalize data with a set center. Useful when mapping data with an unequal rates of change around a conceptual center, e.g., data that range from -2 to 4, with 0 as the midpoint.  Parameters

vcenterfloat

The data value that defines 0.5 in the normalization.
vminfloat, optional

The data value that defines 0.0 in the normalization. Defaults to the min value of the dataset.
vmaxfloat, optional

The data value that defines 1.0 in the normalization. Defaults to the max value of the dataset.     Examples This maps data value -4000 to 0., 0 to 0.5, and +10000 to 1.0; data between is linearly interpolated: >>> import matplotlib.colors as mcolors
>>> offset = mcolors.TwoSlopeNorm(vmin=-4000.,
                                  vcenter=0., vmax=10000)
>>> data = [-4000., -2000., 0., 2500., 5000., 7500., 10000.]
>>> offset(data)
array([0., 0.25, 0.5, 0.625, 0.75, 0.875, 1.0])
   __call__(value, clip=None)[source]

Map value to the interval [0, 1]. The clip argument is unused.
   autoscale_None(A)[source]

Get vmin and vmax, and then clip at vcenter
   inverse(value)[source]

   propertyvcenter

  Examples using matplotlib.colors.TwoSlopeNorm

   Colormap Normalization


__call__(value, clip=None)[source]

Map value to the interval [0, 1]. The clip argument is unused.


autoscale_None(A)[source]

Get vmin and vmax, and then clip at vcenter


matplotlib.container   classmatplotlib.container.BarContainer(*args, **kwargs)[source]

Bases: matplotlib.container.Container Container for the artists of bar plots (e.g. created by Axes.bar). The container can be treated as a tuple of the patches themselves. Additionally, you can access these and further parameters by the attributes.  Attributes

patcheslist of Rectangle

The artists of the bars.
errorbarNone or ErrorbarContainer

A container for the error bar artists if error bars are present. None otherwise.
datavaluesNone or array-like

The underlying data values corresponding to the bars.
orientation{'vertical', 'horizontal'}, default: None

If 'vertical', the bars are assumed to be vertical. If 'horizontal', the bars are assumed to be horizontal.
   classmatplotlib.container.Container(*args, **kwargs)[source]

Bases: tuple Base class for containers. Containers are classes that collect semantically related Artists such as the bars of a bar plot.   add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.  Parameters

funccallable

The callback function. It must have the signature: def func(artist: Artist) -> Any
 where artist is the calling Artist. Return values may exist but are ignored.    Returns
 int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.      See also  remove_callback

   get_children()[source]

   get_label()[source]

Return the label used for this artist in the legend.
   pchanged()[source]

Call all of the registered callbacks. This function is triggered internally when a property is changed.  See also  add_callback
remove_callback

   remove()[source]

   remove_callback(oid)[source]

Remove a callback based on its observer id.  See also  add_callback

   set_label(s)[source]

Set a label that will be displayed in the legend.  Parameters

sobject

s will be converted to a string by calling str.

   classmatplotlib.container.ErrorbarContainer(*args, **kwargs)[source]

Bases: matplotlib.container.Container Container for the artists of error bars (e.g. created by Axes.errorbar). The container can be treated as the lines tuple itself. Additionally, you can access these and further parameters by the attributes.  Attributes

linestuple

Tuple of (data_line, caplines, barlinecols).  data_line : Line2D instance of x, y plot markers and/or line. caplines : tuple of Line2D instances of the error bar caps. barlinecols : list of LineCollection with the horizontal and vertical error ranges.
has_xerr, has_yerrbool

True if the errorbar has x/y errors.
   classmatplotlib.container.StemContainer(*args, **kwargs)[source]

Bases: matplotlib.container.Container Container for the artists created in a Axes.stem() plot. The container can be treated like a namedtuple (markerline, stemlines,
baseline).  Attributes

markerlineLine2D

The artist of the markers at the stem heads.
stemlineslist of Line2D

The artists of the vertical lines for all stems.
baselineLine2D

The artist of the horizontal baseline.      Parameters

markerline_stemlines_baselinetuple

Tuple of (markerline, stemlines, baseline). markerline contains the LineCollection of the markers, stemlines is a LineCollection of the main lines, baseline is the Line2D of the baseline.


classmatplotlib.container.BarContainer(*args, **kwargs)[source]

Bases: matplotlib.container.Container Container for the artists of bar plots (e.g. created by Axes.bar). The container can be treated as a tuple of the patches themselves. Additionally, you can access these and further parameters by the attributes.  Attributes

patcheslist of Rectangle

The artists of the bars.
errorbarNone or ErrorbarContainer

A container for the error bar artists if error bars are present. None otherwise.
datavaluesNone or array-like

The underlying data values corresponding to the bars.
orientation{'vertical', 'horizontal'}, default: None

If 'vertical', the bars are assumed to be vertical. If 'horizontal', the bars are assumed to be horizontal.


classmatplotlib.container.Container(*args, **kwargs)[source]

Bases: tuple Base class for containers. Containers are classes that collect semantically related Artists such as the bars of a bar plot.   add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.  Parameters

funccallable

The callback function. It must have the signature: def func(artist: Artist) -> Any
 where artist is the calling Artist. Return values may exist but are ignored.    Returns
 int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.      See also  remove_callback

   get_children()[source]

   get_label()[source]

Return the label used for this artist in the legend.
   pchanged()[source]

Call all of the registered callbacks. This function is triggered internally when a property is changed.  See also  add_callback
remove_callback

   remove()[source]

   remove_callback(oid)[source]

Remove a callback based on its observer id.  See also  add_callback

   set_label(s)[source]

Set a label that will be displayed in the legend.  Parameters

sobject

s will be converted to a string by calling str.


add_callback(func)[source]

Add a callback function that will be called whenever one of the Artist's properties changes.  Parameters

funccallable

The callback function. It must have the signature: def func(artist: Artist) -> Any
 where artist is the calling Artist. Return values may exist but are ignored.    Returns
 int

The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.      See also  remove_callback


get_label()[source]

Return the label used for this artist in the legend.


pchanged()[source]

Call all of the registered callbacks. This function is triggered internally when a property is changed.  See also  add_callback
remove_callback


remove_callback(oid)[source]

Remove a callback based on its observer id.  See also  add_callback


set_label(s)[source]

Set a label that will be displayed in the legend.  Parameters

sobject

s will be converted to a string by calling str.