doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
set_pickradius(pr)[source] Set the pick radius used for containment tests. Parameters prfloat Pick radius, in points.
matplotlib.collections_api#matplotlib.collections.TriMesh.set_pickradius
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
matplotlib.collections_api#matplotlib.collections.TriMesh.set_rasterized
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.
matplotlib.collections_api#matplotlib.collections.TriMesh.set_sketch_params
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.
matplotlib.collections_api#matplotlib.collections.TriMesh.set_snap
set_transform(t)[source] Set the artist transform. Parameters tTransform
matplotlib.collections_api#matplotlib.collections.TriMesh.set_transform
set_url(url)[source] Set the url for the artist. Parameters urlstr
matplotlib.collections_api#matplotlib.collections.TriMesh.set_url
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.
matplotlib.collections_api#matplotlib.collections.TriMesh.set_urls
set_visible(b)[source] Set the artist's visibility. Parameters bbool
matplotlib.collections_api#matplotlib.collections.TriMesh.set_visible
set_zorder(level)[source] Set the zorder for the artist. Artists with lower zorder values are drawn first. Parameters levelfloat
matplotlib.collections_api#matplotlib.collections.TriMesh.set_zorder
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).
matplotlib.collections_api#matplotlib.collections.TriMesh.to_rgba
update(props)[source] Update this artist's properties from the dict props. Parameters propsdict
matplotlib.collections_api#matplotlib.collections.TriMesh.update
update_from(other)[source] Copy properties from other to self.
matplotlib.collections_api#matplotlib.collections.TriMesh.update_from
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.collections_api#matplotlib.collections.TriMesh.update_scalarmappable
zorder=0
matplotlib.collections_api#matplotlib.collections.TriMesh.zorder
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.
matplotlib.colorbar_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_api#matplotlib.colorbar.Colorbar
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.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.add_lines
drag_pan(button, key, x, y)[source]
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.drag_pan
draw_all()[source] Calculate any free parameters based on the current cmap and norm, and do all the drawing.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.draw_all
get_ticks(minor=False)[source] Return the ticks as a list of locations. Parameters minorboolean, default: False if True return the minor ticks.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.get_ticks
minorticks_off()[source] Turn the minor ticks of the colorbar off.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.minorticks_off
minorticks_on()[source] Turn on colorbar minor ticks.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.minorticks_on
n_rasterize=50
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.n_rasterize
remove()[source] Remove this colorbar from the figure. If the colorbar was created with use_gridspec=True the previous gridspec is restored.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.remove
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.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.set_alpha
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.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.set_label
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.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.set_ticklabels
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.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.set_ticks
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.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.update_normal
update_ticks()[source] Setup the ticks and ticklabels. This should not be needed by users.
matplotlib.colorbar_api#matplotlib.colorbar.Colorbar.update_ticks
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_api#matplotlib.colorbar.colorbar_factory
matplotlib.colorbar.ColorbarBase[source] alias of matplotlib.colorbar.Colorbar
matplotlib.colorbar_api#matplotlib.colorbar.ColorbarBase
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_api#matplotlib.colorbar.ColorbarPatch
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_api#matplotlib.colorbar.make_axes
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.colorbar_api#matplotlib.colorbar.make_axes_gridspec
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_configuration_api#matplotlib.colormaps
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_api
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
matplotlib._as_gen.matplotlib.colors.boundarynorm
__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._as_gen.matplotlib.colors.boundarynorm#matplotlib.colors.BoundaryNorm.__call__
inverse(value)[source] Raises ValueError BoundaryNorm is not invertible, so calling this method will always raise an error
matplotlib._as_gen.matplotlib.colors.boundarynorm#matplotlib.colors.BoundaryNorm.inverse
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
matplotlib._as_gen.matplotlib.colors.centerednorm
__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._as_gen.matplotlib.colors.centerednorm#matplotlib.colors.CenteredNorm.__call__
autoscale(A)[source] Set halfrange to max(abs(A-vcenter)), then set vmin and vmax.
matplotlib._as_gen.matplotlib.colors.centerednorm#matplotlib.colors.CenteredNorm.autoscale
autoscale_None(A)[source] Set vmin and vmax.
matplotlib._as_gen.matplotlib.colors.centerednorm#matplotlib.colors.CenteredNorm.autoscale_None
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
matplotlib._as_gen.matplotlib.colors.colormap
__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, ).
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.__call__
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.
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.colorbar_extend
copy()[source] Return a copy of the colormap.
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.copy
get_bad()[source] Get the color for masked values.
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.get_bad
get_over()[source] Get the color for high out-of-range values.
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.get_over
get_under()[source] Get the color for low out-of-range values.
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.get_under
is_gray()[source] Return whether the colormap is grayscale.
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.is_gray
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
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.reversed
set_bad(color='k', alpha=None)[source] Set the color for masked values.
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.set_bad
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.
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.set_extremes
set_over(color='k', alpha=None)[source] Set the color for high out-of-range values.
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.set_over
set_under(color='k', alpha=None)[source] Set the color for low out-of-range values.
matplotlib._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.set_under
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._as_gen.matplotlib.colors.colormap#matplotlib.colors.Colormap.with_extremes
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._as_gen.matplotlib.colors.from_levels_and_colors
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
matplotlib._as_gen.matplotlib.colors.funcnorm
__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._as_gen.matplotlib.colors.funcnorm#matplotlib.colors.FuncNorm.__call__
inverse(value)[source]
matplotlib._as_gen.matplotlib.colors.funcnorm#matplotlib.colors.FuncNorm.inverse
matplotlib.colors.get_named_colors_mapping matplotlib.colors.get_named_colors_mapping()[source] Return the global mapping of names to named colors.
matplotlib._as_gen.matplotlib.colors.get_named_colors_mapping
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._as_gen.matplotlib.colors.hsv_to_rgb
matplotlib.colors.is_color_like matplotlib.colors.is_color_like(c)[source] Return whether c can be interpreted as an RGB(A) color.
matplotlib._as_gen.matplotlib.colors.is_color_like
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
matplotlib._as_gen.matplotlib.colors.lightsource
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.
matplotlib._as_gen.matplotlib.colors.lightsource#matplotlib.colors.LightSource.blend_hsv
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.
matplotlib._as_gen.matplotlib.colors.lightsource#matplotlib.colors.LightSource.blend_overlay
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.
matplotlib._as_gen.matplotlib.colors.lightsource#matplotlib.colors.LightSource.blend_soft_light
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.
matplotlib._as_gen.matplotlib.colors.lightsource#matplotlib.colors.LightSource.hillshade
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.
matplotlib._as_gen.matplotlib.colors.lightsource#matplotlib.colors.LightSource.shade
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.
matplotlib._as_gen.matplotlib.colors.lightsource#matplotlib.colors.LightSource.shade_normals
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._as_gen.matplotlib.colors.lightsource#matplotlib.colors.LightSource.shade_rgb
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
matplotlib._as_gen.matplotlib.colors.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
matplotlib._as_gen.matplotlib.colors.linearsegmentedcolormap#matplotlib.colors.LinearSegmentedColormap.from_list
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.
matplotlib._as_gen.matplotlib.colors.linearsegmentedcolormap#matplotlib.colors.LinearSegmentedColormap.reversed
set_gamma(gamma)[source] Set a new gamma value and regenerate colormap.
matplotlib._as_gen.matplotlib.colors.linearsegmentedcolormap#matplotlib.colors.LinearSegmentedColormap.set_gamma
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
matplotlib._as_gen.matplotlib.colors.listedcolormap
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._as_gen.matplotlib.colors.listedcolormap#matplotlib.colors.ListedColormap.reversed
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
matplotlib._as_gen.matplotlib.colors.lognorm
__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._as_gen.matplotlib.colors.lognorm#matplotlib.colors.LogNorm.__call__
inverse(value)[source]
matplotlib._as_gen.matplotlib.colors.lognorm#matplotlib.colors.LogNorm.inverse
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._as_gen.matplotlib.colors.make_norm_from_scale
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._as_gen.matplotlib.colors.nonorm
__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._as_gen.matplotlib.colors.nonorm#matplotlib.colors.NoNorm.__call__
inverse(value)[source]
matplotlib._as_gen.matplotlib.colors.nonorm#matplotlib.colors.NoNorm.inverse
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
matplotlib._as_gen.matplotlib.colors.normalize
__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._as_gen.matplotlib.colors.normalize#matplotlib.colors.Normalize.__call__
autoscale(A)[source] Set vmin, vmax to min, max of A.
matplotlib._as_gen.matplotlib.colors.normalize#matplotlib.colors.Normalize.autoscale
autoscale_None(A)[source] If vmin or vmax are not set, use the min/max of A to set them.
matplotlib._as_gen.matplotlib.colors.normalize#matplotlib.colors.Normalize.autoscale_None
inverse(value)[source]
matplotlib._as_gen.matplotlib.colors.normalize#matplotlib.colors.Normalize.inverse
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.
matplotlib._as_gen.matplotlib.colors.normalize#matplotlib.colors.Normalize.process_value
scaled()[source] Return whether vmin and vmax are set.
matplotlib._as_gen.matplotlib.colors.normalize#matplotlib.colors.Normalize.scaled
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._as_gen.matplotlib.colors.powernorm
__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._as_gen.matplotlib.colors.powernorm#matplotlib.colors.PowerNorm.__call__
inverse(value)[source]
matplotlib._as_gen.matplotlib.colors.powernorm#matplotlib.colors.PowerNorm.inverse
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._as_gen.matplotlib.colors.rgb_to_hsv
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._as_gen.matplotlib.colors.same_color
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._as_gen.matplotlib.colors.symlognorm
__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._as_gen.matplotlib.colors.symlognorm#matplotlib.colors.SymLogNorm.__call__