Return the global mapping of names to named colors.


Convert hsv values to rgb.
All values assumed to be in range [0, 1]
Colors converted to RGB values in range [0, 1]
3D voxel / volumetric plot with cylindrical coordinates


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


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.
The azimuth (0-360, degrees clockwise from North) of the light source.
The altitude (0-90, degrees up from horizontal) of the light source.
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.
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).
An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
An MxNx1 array of floats ranging from 0 to 1 (grayscale image).
The maximum saturation value that the intensity map can shift the output image to.
The minimum saturation value that the intensity map can shift the output image to. Defaults to 0.
The maximum value ("v" in "hsv") that the intensity map can shift the output image to. Defaults to 1.
The minimum value ("v" in "hsv") that the intensity map can shift the output image to. Defaults to 0.
An MxNx3 RGB array representing the combined images.
Combine an rgb image with an intensity map using "overlay" blending.
An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
An MxNx1 array of floats ranging from 0 to 1 (grayscale image).
An MxNx3 RGB array representing the combined images.
Combine an rgb image with an intensity map using "soft light" blending, using the "pegtop" formula.
An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
An MxNx1 array of floats ranging from 0 to 1 (grayscale image).
An MxNx3 RGB array representing the combined images.
The unit vector direction towards the light 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
The height values used to generate an illumination map
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.
The x-spacing (columns) of the input elevation grid.
The y-spacing (rows) of the input elevation grid.
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.
A 2D array of illumination values between 0-1, where 0 is completely in shadow and 1 is completely illuminated.
Combine colormapped data values with an illumination intensity map (a.k.a. "hillshade") of the values.
The height values used to generate a shaded map.
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.
The normalization used to scale values before colormapping. If None, the input will be linearly scaled between its min and max.
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.
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.
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.
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.
The x-spacing (columns) of the input elevation grid.
The y-spacing (rows) of the input elevation grid.
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.
An MxNx4 array of floats ranging between 0-1.
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.
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.
A 2D array of illumination values between 0-1, where 0 is completely in shadow and 1 is completely illuminated.
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.
An (M, N, 3) RGB array, assumed to be in the range of 0 to 1.
An (M, N) array of the height values used to generate a shaded map.
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.
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.
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.
The x-spacing (columns) of the input elevation grid.
The y-spacing (rows) of the input elevation grid.
An (m, n, 3) array of floats ranging between 0-1.
Shading example
Shaded & power normalized rendering
Frontpage 3D example
AGG filter
Custom hillshading in a 3D surface plot
Hillshading
Topographic hillshading


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).
An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
An MxNx1 array of floats ranging from 0 to 1 (grayscale image).
The maximum saturation value that the intensity map can shift the output image to.
The minimum saturation value that the intensity map can shift the output image to. Defaults to 0.
The maximum value ("v" in "hsv") that the intensity map can shift the output image to. Defaults to 1.
The minimum value ("v" in "hsv") that the intensity map can shift the output image to. Defaults to 0.
An MxNx3 RGB array representing the combined images.


Combine an rgb image with an intensity map using "overlay" blending.
An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
An MxNx1 array of floats ranging from 0 to 1 (grayscale image).
An MxNx3 RGB array representing the combined images.


Combine an rgb image with an intensity map using "soft light" blending, using the "pegtop" formula.
An MxNx3 RGB array of floats ranging from 0 to 1 (color image).
An MxNx1 array of floats ranging from 0 to 1 (grayscale image).
An MxNx3 RGB array representing the combined images.


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
The height values used to generate an illumination map
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.
The x-spacing (columns) of the input elevation grid.
The y-spacing (rows) of the input elevation grid.
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.
A 2D array of illumination values between 0-1, where 0 is completely in shadow and 1 is completely illuminated.


Combine colormapped data values with an illumination intensity map (a.k.a. "hillshade") of the values.
The height values used to generate a shaded map.
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.
The normalization used to scale values before colormapping. If None, the input will be linearly scaled between its min and max.
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.
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.
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.
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.
The x-spacing (columns) of the input elevation grid.
The y-spacing (rows) of the input elevation grid.
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.
An MxNx4 array of floats ranging between 0-1.


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.
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.
A 2D array of illumination values between 0-1, where 0 is completely in shadow and 1 is completely illuminated.


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.
An (M, N, 3) RGB array, assumed to be in the range of 0 to 1.
An (M, N) array of the height values used to generate a shaded map.
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.
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.
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.
The x-spacing (columns) of the input elevation grid.
The y-spacing (rows) of the input elevation grid.
An (m, n, 3) array of floats ranging between 0-1.


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:
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]:
Hence y0 in the first row and y1 in the last row are never used.
See also
Static method; factory function for generating a smoothly-varying LinearSegmentedColormap.
Create a LinearSegmentedColormap from a list of colors.
The name of the colormap.
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.
The number of rgb quantization levels.
Return a reversed instance of the Colormap.
The name for the reversed colormap. If it's None the name will be the name of the parent colormap + "_r".
The reversed colormap.
Set a new gamma value and regenerate colormap.
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


Create a LinearSegmentedColormap from a list of colors.
The name of the colormap.
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.
The number of rgb quantization levels.


Return a reversed instance of the Colormap.
The name for the reversed colormap. If it's None the name will be the name of the parent colormap + "_r".
The reversed colormap.


Set a new gamma value and regenerate colormap.


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.
List of Matplotlib color specifications, or an equivalent Nx3 or Nx4 floating point array (N rgb or rgba values).
String to identify the colormap.
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
the list will be truncated at N. If
the list will be extended by repetition.
The name of the colormap.
The number of rgb quantization levels.
Return a reversed instance of the Colormap.
The name for the reversed colormap. If it's None the name will be the name of the parent colormap + "_r".
A reversed instance of the colormap.
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


Return a reversed instance of the Colormap.
The name for the reversed colormap. If it's None the name will be the name of the parent colormap + "_r".
A reversed instance of the colormap.


Bases: matplotlib.colors.LogNorm
Normalize a given value to the 0-1 range on a log scale.
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).
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.
Returns 0 if vmin == vmax.
Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.
Data to normalize.
If None, defaults to self.clip (which defaults to False).
If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
Pcolor Demo
Histograms
Time Series Histogram
Colormap Normalizations
Basic Usage
Colormap Normalization


Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.
Data to normalize.
If None, defaults to self.clip (which defaults to False).
If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).


Decorator for building a Normalize subclass from a ScaleBase subclass.
After
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.


Bases: matplotlib.colors.Normalize
Dummy replacement for Normalize, for the case where we want to use indices directly in a ScalarMappable.
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).
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.
Returns 0 if vmin == vmax.
Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.
Data to normalize.
If None, defaults to self.clip (which defaults to False).
If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).


Bases: object
A class which, when called, linearly normalizes data into the [0.0, 1.0] interval.
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).
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.
Returns 0 if vmin == vmax.
Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.
Data to normalize.
If None, defaults to self.clip (which defaults to False).
If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
Set vmin, vmax to min, max of A.
If vmin or vmax are not set, use the min/max of A to set them.
Homogenize the input value for easy and efficient normalization.
value can be a scalar or sequence.
Masked array with the same shape as value.
Whether value is a scalar.
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.
Return whether vmin and vmax are set.
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


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


Homogenize the input value for easy and efficient normalization.
value can be a scalar or sequence.
Masked array with the same shape as value.
Whether value is a scalar.
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.


Bases: matplotlib.colors.Normalize
Linearly map a given value to the 0-1 range and then apply a power-law normalization over that range.
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).
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.
Returns 0 if vmin == vmax.
Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.
Data to normalize.
If None, defaults to self.clip (which defaults to False).
If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
Shaded & power normalized rendering
Exploring normalizations
Colormap Normalizations
Colormap Normalization


Convert float rgb values (in the range [0, 1]), in a numpy array to hsv values.
All values must be in the range [0, 1]
Colors converted to hsv values in range [0, 1]
List of named colors


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


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).
The range within which the plot is linear (to avoid having the plot go to infinity around zero).
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.
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).
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.
Returns 0 if vmin == vmax.
Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.
Data to normalize.
If None, defaults to self.clip (which defaults to False).
If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).
Colormap Normalizations
Colormap Normalizations Symlognorm
Colormap Normalization


Convert c to a hex color.
If False, use the #rrggbb format, otherwise use #rrggbbaa.
#rrggbb or #rrggbbaa hex color string


Convert c to an RGB color, silently dropping the alpha channel.
List of named colors


Convert c to an RGBA color.
If alpha is given, force the alpha value of the returned RGBA tuple to alpha.
If None, the alpha value from c is used. If c does not have an alpha channel, then alpha defaults to 1.
alpha is ignored for the color value "none" (case-insensitive), which always maps to (0, 0, 0, 0).
Tuple of floats (r, g, b, a), where each channel (red, green, blue, alpha) can assume values between 0 and 1.
Line, Poly and RegularPoly Collection with autoscaling
Line Collection
Lasso Demo
Ribbon Box


Convert c to a (n, 4) array of RGBA colors.
If c is a masked array, an ndarray is returned with a (0, 0, 0, 0) row for each masked value or row in c.
If alpha is given, force the alpha value of the returned RGBA tuple to alpha.
If None, the alpha value from c is used. If c does not have an alpha channel, then alpha defaults to 1.
alpha is ignored for the color value "none" (case-insensitive), which always maps to (0, 0, 0, 0).
If alpha is a sequence and c is a single color, c will be repeated to match the length of alpha.
(n, 4) array of RGBA colors, where each channel (red, green, blue, alpha) can assume values between 0 and 1.
Specifying Colors


Bases: matplotlib.colors.Normalize
Normalize data with a set center.
Useful when mapping data with an unequal rates of change around a conceptual center, e.g., data that range from -2 to 4, with 0 as the midpoint.
The data value that defines 0.5 in the normalization.
The data value that defines 0.0 in the normalization. Defaults to the min value of the dataset.
The data value that defines 1.0 in the normalization. Defaults to the max value of the dataset.
This maps data value -4000 to 0., 0 to 0.5, and +10000 to 1.0; data between is linearly interpolated:
Map value to the interval [0, 1]. The clip argument is unused.
Get vmin and vmax, and then clip at vcenter
Colormap Normalization


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


Get vmin and vmax, and then clip at vcenter


Bases: matplotlib.container.Container
Container for the artists of bar plots (e.g. created by Axes.bar).
The container can be treated as a tuple of the patches themselves. Additionally, you can access these and further parameters by the attributes.
The artists of the bars.
A container for the error bar artists if error bars are present. None otherwise.
The underlying data values corresponding to the bars.
If 'vertical', the bars are assumed to be vertical. If 'horizontal', the bars are assumed to be horizontal.
Bases: tuple
Base class for containers.
Containers are classes that collect semantically related Artists such as the bars of a bar plot.
Add a callback function that will be called whenever one of the Artist's properties changes.
The callback function. It must have the signature:
where artist is the calling Artist. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.
See also
Return the label used for this artist in the legend.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
Remove a callback based on its observer id.
See also
Set a label that will be displayed in the legend.
s will be converted to a string by calling str.
Bases: matplotlib.container.Container
Container for the artists of error bars (e.g. created by Axes.errorbar).
The container can be treated as the lines tuple itself. Additionally, you can access these and further parameters by the attributes.
Tuple of (data_line, caplines, barlinecols).
True if the errorbar has x/y errors.
Bases: matplotlib.container.Container
Container for the artists created in a Axes.stem() plot.
The container can be treated like a namedtuple (markerline, stemlines,
baseline).
The artist of the markers at the stem heads.
The artists of the vertical lines for all stems.
The artist of the horizontal baseline.
Tuple of (markerline, stemlines, baseline). markerline contains the LineCollection of the markers, stemlines is a LineCollection of the main lines, baseline is the Line2D of the baseline.


Bases: matplotlib.container.Container
Container for the artists of bar plots (e.g. created by Axes.bar).
The container can be treated as a tuple of the patches themselves. Additionally, you can access these and further parameters by the attributes.
The artists of the bars.
A container for the error bar artists if error bars are present. None otherwise.
The underlying data values corresponding to the bars.
If 'vertical', the bars are assumed to be vertical. If 'horizontal', the bars are assumed to be horizontal.


Bases: tuple
Base class for containers.
Containers are classes that collect semantically related Artists such as the bars of a bar plot.
Add a callback function that will be called whenever one of the Artist's properties changes.
The callback function. It must have the signature:
where artist is the calling Artist. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.
See also
Return the label used for this artist in the legend.
Call all of the registered callbacks.
This function is triggered internally when a property is changed.
See also
Remove a callback based on its observer id.
See also
Set a label that will be displayed in the legend.
s will be converted to a string by calling str.


Add a callback function that will be called whenever one of the Artist's properties changes.
The callback function. It must have the signature:
where artist is the calling Artist. Return values may exist but are ignored.
The observer id associated with the callback. This id can be used for removing the callback with remove_callback later.
See also


Return the label used for this artist in the legend.


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


Remove a callback based on its observer id.
See also


Set a label that will be displayed in the legend.
s will be converted to a string by calling str.


Bases: matplotlib.container.Container
Container for the artists of error bars (e.g. created by Axes.errorbar).
The container can be treated as the lines tuple itself. Additionally, you can access these and further parameters by the attributes.
Tuple of (data_line, caplines, barlinecols).
True if the errorbar has x/y errors.


Bases: matplotlib.container.Container
Container for the artists created in a Axes.stem() plot.
The container can be treated like a namedtuple (markerline, stemlines,
baseline).
The artist of the markers at the stem heads.
The artists of the vertical lines for all stems.
The artist of the horizontal baseline.
Tuple of (markerline, stemlines, baseline). markerline contains the LineCollection of the markers, stemlines is a LineCollection of the main lines, baseline is the Line2D of the baseline.


Classes to support contour plotting and labelling for the Axes class.
Bases: matplotlib.text.Text
Unlike the ordinary text, the get_rotation returns an updated angle in the pixel coordinate assuming that the input rotation is an angle in data coordinate (or whatever transform set).
Create a Text instance at x, y with string text.
Valid keyword arguments are:
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
backgroundcolor
color
bbox
dict with properties for patches.FancyBboxPatch
clip_box
unknown
clip_on
unknown
clip_path
unknown
color or c
color
figure
Figure
fontfamily or family
{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
fontproperties or font or font_properties
font_manager.FontProperties or str or pathlib.Path
fontsize or size
float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
fontstretch or stretch
{a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}
fontstyle or style
{'normal', 'italic', 'oblique'}
fontvariant or variant
{'normal', 'small-caps'}
fontweight or weight
{a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}
gid
str
horizontalalignment or ha
{'center', 'right', 'left'}
in_layout
bool
label
object
linespacing
float (multiple of font size)
math_fontfamily
str
multialignment or ma
{'left', 'right', 'center'}
parse_math
bool
path_effects
AbstractPathEffect
picker
None or bool or float or callable
position
(float, float)
rasterized
bool
rotation
float or {'vertical', 'horizontal'}
rotation_mode
{None, 'default', 'anchor'}
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
text
object
transform
Transform
transform_rotates_text
bool
url
str
usetex
bool or None
verticalalignment or va
{'center', 'top', 'bottom', 'baseline', 'center_baseline'}
visible
bool
wrap
bool
x
float
y
float
zorder
float
Return the text angle in degrees between 0 and 360.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
backgroundcolor
color
bbox
dict with properties for patches.FancyBboxPatch
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color or c
color
figure
Figure
fontfamily or family
{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
fontproperties or font or font_properties
font_manager.FontProperties or str or pathlib.Path
fontsize or size
float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
fontstretch or stretch
{a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}
fontstyle or style
{'normal', 'italic', 'oblique'}
fontvariant or variant
{'normal', 'small-caps'}
fontweight or weight
{a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}
gid
str
horizontalalignment or ha
{'center', 'right', 'left'}
in_layout
bool
label
object
linespacing
float (multiple of font size)
math_fontfamily
str
multialignment or ma
{'left', 'right', 'center'}
parse_math
bool
path_effects
AbstractPathEffect
picker
None or bool or float or callable
position
(float, float)
rasterized
bool
rotation
float or {'vertical', 'horizontal'}
rotation_mode
{None, 'default', 'anchor'}
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
text
object
transform
Transform
transform_rotates_text
bool
url
str
usetex
bool or None
verticalalignment or va
{'center', 'top', 'bottom', 'baseline', 'center_baseline'}
visible
bool
wrap
bool
x
float
y
float
zorder
float
Bases: object
Mixin to provide labelling capability to ContourSet.
Add contour label using Text class.
Add contour label using ClabelText class.
Add a label near the point (x, y).
The approximate location of the label.
If True remove the segment of the contour beneath the label.
Space in pixels to leave on each side of label when placing inline. This spacing will be exact for labels at locations where the contour is straight, less so for labels on curved contours.
A transform applied to (x, y) before labeling. The default causes (x, y) to be interpreted as data coordinates. False is a synonym for IdentityTransform; i.e. (x, y) should be interpreted as display coordinates.
Calculate the appropriate label rotation given the linecontour coordinates in screen units, the index of the label location and the label width.
If lc is not None or empty, also break contours and compute inlining.
spacing is the empty space to leave around the label, in pixels.
Both tasks are done together to avoid calculating path lengths multiple times, which is relatively costly.
The method used here involves computing the path length along the contour in pixel coordinates and then looking approximately (label width / 2) away from central point to determine rotation and then to break contour if desired.
Label a contour plot.
Adds labels to line contours in this ContourSet (which inherits from this mixin class).
A list of level values, that should be labeled. The list must be a subset of cs.levels. If not given, all levels are labeled.
Size in points or relative size e.g., 'smaller', 'x-large'. See Text.set_size for accepted string values.
The label colors:
If True the underlying contour is removed where the label is placed.
Space in pixels to leave on each side of label when placing inline.
This spacing will be exact for labels at locations where the contour is straight, less so for labels on curved contours.
How the levels are formatted:
The default is to use a standard ScalarFormatter.
If True, contour labels will be placed manually using mouse clicks. Click the first button near a contour to add a label, click the second button (or potentially both mouse buttons at once) to finish adding labels. The third button can be used to remove the last label added, but only if labels are not inline. Alternatively, the keyboard can be used to select label locations (enter to end label placement, delete or backspace act like the third mouse button, and any other key will select a label location).
manual can also be an iterable object of (x, y) tuples. Contour labels will be created as if mouse is clicked at each (x, y) position.
If True, label rotations will always be plus or minus 90 degrees from level.
If True, ClabelText class (instead of Text) is used to create labels. ClabelText recalculates rotation angles of texts during the drawing time, therefore this can be used if aspect of the axes changes.
zorder of the contour labels.
A list of Text instances for the labels.
[Deprecated] Return x, y, and the index of a label location.
Labels are plotted at a location with the smallest deviation of the contour from a straight line unless there is another label nearby, in which case the next best place on the contour is picked up. If all such candidates are rejected, the beginning of the contour is chosen.
Deprecated since version 3.4.
[Deprecated] Return the width of the label in points.
Deprecated since version 3.5.
Get the text of the label.
Find good place to draw a label (relatively flat part of the contour).
Defaults to removing last label, but any index can be supplied
Return whether a contour is long enough to hold a label.
Set the label properties - color, fontsize, text.
Return whether a label is already near this location.
Bases: matplotlib.cm.ScalarMappable, matplotlib.contour.ContourLabeler
Store a set of contour lines or filled regions.
User-callable method: clabel
A list of floating point numbers indicating the contour levels.
List of all the polygon segments for all the levels. For contour lines len(allsegs) == len(levels), and for filled contour regions len(allsegs) = len(levels)-1. The lists should look like
Optional list of all the polygon vertex kinds (code types), as described and used in Path. This is used to allow multiply- connected paths such as holes within filled polygons. If not None, len(allkinds) == len(allsegs). The lists should look like
If allkinds is not None, usually all polygons for a particular contour level are grouped together so that level0segs = [polygon0] and level0kinds = [polygon0kinds].
Keyword arguments are as described in the docstring of contour.
The Axes object in which the contours are drawn.
The Artists representing the contour. This is a list of PathCollections for both line and filled contours.
The values of the contour levels.
Same as levels for line contours; half-way between levels for filled contours. See ContourSet._process_colors.
Draw contour lines or filled regions, depending on whether keyword arg filled is False (default) or True.
Call signature:
The Axes object to draw on.
A list of floating point numbers indicating the contour levels.
List of all the polygon segments for all the levels. For contour lines len(allsegs) == len(levels), and for filled contour regions len(allsegs) = len(levels)-1. The lists should look like
Optional list of all the polygon vertex kinds (code types), as described and used in Path. This is used to allow multiply- connected paths such as holes within filled polygons. If not None, len(allkinds) == len(allsegs). The lists should look like
If allkinds is not None, usually all polygons for a particular contour level are grouped together so that level0segs = [polygon0] and level0kinds = [polygon0kinds].
Keyword arguments are as described in the docstring of contour.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
Find the point in the contour plot that is closest to (x, y).
The reference point.
Indices of contour levels to consider. If None (the default), all levels are considered.
If True, measure distance in pixel (screen) space, which is useful for manual contour labeling; else, measure distance in axes space.
The contour that is closest to (x, y).
The index of the Path in contour that is closest to (x, y).
The index of the path segment in segment that is closest to (x, y).
The point in the contour plot that is closest to (x, y).
The squared distance from (xmin, ymin) to (x, y).
Return alpha to be applied to all ContourSet artists.
Return the Transform instance used by this ContourSet.
Return a list of artists and labels suitable for passing through to legend which represent this ContourSet.
The labels have the form "0 < x <= 1" stating the data ranges which the artists represent.
The string used inside the inequality used on the labels.
Function used to format the numbers in the labels.
A list of the artists.
A list of the labels.
Set the alpha blending value for all ContourSet artists. alpha must be between 0 (transparent) and 1 (opaque).
Bases: matplotlib.contour.ContourSet
Create and store a set of contour lines or filled regions.
This class is typically not instantiated directly by the user but by contour and contourf.
The Axes object in which the contours are drawn.
The Artists representing the contour. This is a list of PathCollections for both line and filled contours.
The values of the contour levels.
Same as levels for line contours; half-way between levels for filled contours. See ContourSet._process_colors.
Draw contour lines or filled regions, depending on whether keyword arg filled is False (default) or True.
Call signature:
The Axes object to draw on.
A list of floating point numbers indicating the contour levels.
List of all the polygon segments for all the levels. For contour lines len(allsegs) == len(levels), and for filled contour regions len(allsegs) = len(levels)-1. The lists should look like
Optional list of all the polygon vertex kinds (code types), as described and used in Path. This is used to allow multiply- connected paths such as holes within filled polygons. If not None, len(allkinds) == len(allsegs). The lists should look like
If allkinds is not None, usually all polygons for a particular contour level are grouped together so that level0segs = [polygon0] and level0kinds = [polygon0kinds].
Keyword arguments are as described in the docstring of contour.


Bases: matplotlib.text.Text
Unlike the ordinary text, the get_rotation returns an updated angle in the pixel coordinate assuming that the input rotation is an angle in data coordinate (or whatever transform set).
Create a Text instance at x, y with string text.
Valid keyword arguments are:
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
backgroundcolor
color
bbox
dict with properties for patches.FancyBboxPatch
clip_box
unknown
clip_on
unknown
clip_path
unknown
color or c
color
figure
Figure
fontfamily or family
{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
fontproperties or font or font_properties
font_manager.FontProperties or str or pathlib.Path
fontsize or size
float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
fontstretch or stretch
{a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}
fontstyle or style
{'normal', 'italic', 'oblique'}
fontvariant or variant
{'normal', 'small-caps'}
fontweight or weight
{a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}
gid
str
horizontalalignment or ha
{'center', 'right', 'left'}
in_layout
bool
label
object
linespacing
float (multiple of font size)
math_fontfamily
str
multialignment or ma
{'left', 'right', 'center'}
parse_math
bool
path_effects
AbstractPathEffect
picker
None or bool or float or callable
position
(float, float)
rasterized
bool
rotation
float or {'vertical', 'horizontal'}
rotation_mode
{None, 'default', 'anchor'}
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
text
object
transform
Transform
transform_rotates_text
bool
url
str
usetex
bool or None
verticalalignment or va
{'center', 'top', 'bottom', 'baseline', 'center_baseline'}
visible
bool
wrap
bool
x
float
y
float
zorder
float
Return the text angle in degrees between 0 and 360.
Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
backgroundcolor
color
bbox
dict with properties for patches.FancyBboxPatch
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color or c
color
figure
Figure
fontfamily or family
{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
fontproperties or font or font_properties
font_manager.FontProperties or str or pathlib.Path
fontsize or size
float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
fontstretch or stretch
{a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}
fontstyle or style
{'normal', 'italic', 'oblique'}
fontvariant or variant
{'normal', 'small-caps'}
fontweight or weight
{a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}
gid
str
horizontalalignment or ha
{'center', 'right', 'left'}
in_layout
bool
label
object
linespacing
float (multiple of font size)
math_fontfamily
str
multialignment or ma
{'left', 'right', 'center'}
parse_math
bool
path_effects
AbstractPathEffect
picker
None or bool or float or callable
position
(float, float)
rasterized
bool
rotation
float or {'vertical', 'horizontal'}
rotation_mode
{None, 'default', 'anchor'}
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
text
object
transform
Transform
transform_rotates_text
bool
url
str
usetex
bool or None
verticalalignment or va
{'center', 'top', 'bottom', 'baseline', 'center_baseline'}
visible
bool
wrap
bool
x
float
y
float
zorder
float


Return the text angle in degrees between 0 and 360.


Set multiple properties at once.
Supported properties are
Property
Description
agg_filter
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alpha
scalar or None
animated
bool
backgroundcolor
color
bbox
dict with properties for patches.FancyBboxPatch
clip_box
Bbox
clip_on
bool
clip_path
Patch or (Path, Transform) or None
color or c
color
figure
Figure
fontfamily or family
{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
fontproperties or font or font_properties
font_manager.FontProperties or str or pathlib.Path
fontsize or size
float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
fontstretch or stretch
{a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}
fontstyle or style
{'normal', 'italic', 'oblique'}
fontvariant or variant
{'normal', 'small-caps'}
fontweight or weight
{a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}
gid
str
horizontalalignment or ha
{'center', 'right', 'left'}
in_layout
bool
label
object
linespacing
float (multiple of font size)
math_fontfamily
str
multialignment or ma
{'left', 'right', 'center'}
parse_math
bool
path_effects
AbstractPathEffect
picker
None or bool or float or callable
position
(float, float)
rasterized
bool
rotation
float or {'vertical', 'horizontal'}
rotation_mode
{None, 'default', 'anchor'}
sketch_params
(scale: float, length: float, randomness: float)
snap
bool or None
text
object
transform
Transform
transform_rotates_text
bool
url
str
usetex
bool or None
verticalalignment or va
{'center', 'top', 'bottom', 'baseline', 'center_baseline'}
visible
bool
wrap
bool
x
float
y
float
zorder
float


Bases: object
Mixin to provide labelling capability to ContourSet.
Add contour label using Text class.
Add contour label using ClabelText class.
Add a label near the point (x, y).
The approximate location of the label.
If True remove the segment of the contour beneath the label.
Space in pixels to leave on each side of label when placing inline. This spacing will be exact for labels at locations where the contour is straight, less so for labels on curved contours.
A transform applied to (x, y) before labeling. The default causes (x, y) to be interpreted as data coordinates. False is a synonym for IdentityTransform; i.e. (x, y) should be interpreted as display coordinates.
Calculate the appropriate label rotation given the linecontour coordinates in screen units, the index of the label location and the label width.
If lc is not None or empty, also break contours and compute inlining.
spacing is the empty space to leave around the label, in pixels.
Both tasks are done together to avoid calculating path lengths multiple times, which is relatively costly.
The method used here involves computing the path length along the contour in pixel coordinates and then looking approximately (label width / 2) away from central point to determine rotation and then to break contour if desired.
Label a contour plot.
Adds labels to line contours in this ContourSet (which inherits from this mixin class).
A list of level values, that should be labeled. The list must be a subset of cs.levels. If not given, all levels are labeled.
Size in points or relative size e.g., 'smaller', 'x-large'. See Text.set_size for accepted string values.
The label colors:
If True the underlying contour is removed where the label is placed.
Space in pixels to leave on each side of label when placing inline.
This spacing will be exact for labels at locations where the contour is straight, less so for labels on curved contours.
How the levels are formatted:
The default is to use a standard ScalarFormatter.
If True, contour labels will be placed manually using mouse clicks. Click the first button near a contour to add a label, click the second button (or potentially both mouse buttons at once) to finish adding labels. The third button can be used to remove the last label added, but only if labels are not inline. Alternatively, the keyboard can be used to select label locations (enter to end label placement, delete or backspace act like the third mouse button, and any other key will select a label location).
manual can also be an iterable object of (x, y) tuples. Contour labels will be created as if mouse is clicked at each (x, y) position.
If True, label rotations will always be plus or minus 90 degrees from level.
If True, ClabelText class (instead of Text) is used to create labels. ClabelText recalculates rotation angles of texts during the drawing time, therefore this can be used if aspect of the axes changes.
zorder of the contour labels.
A list of Text instances for the labels.
[Deprecated] Return x, y, and the index of a label location.
Labels are plotted at a location with the smallest deviation of the contour from a straight line unless there is another label nearby, in which case the next best place on the contour is picked up. If all such candidates are rejected, the beginning of the contour is chosen.
Deprecated since version 3.4.
[Deprecated] Return the width of the label in points.
Deprecated since version 3.5.
Get the text of the label.
Find good place to draw a label (relatively flat part of the contour).
Defaults to removing last label, but any index can be supplied
Return whether a contour is long enough to hold a label.
Set the label properties - color, fontsize, text.
Return whether a label is already near this location.


Add contour label using ClabelText class.


Add a label near the point (x, y).
The approximate location of the label.
If True remove the segment of the contour beneath the label.
Space in pixels to leave on each side of label when placing inline. This spacing will be exact for labels at locations where the contour is straight, less so for labels on curved contours.
A transform applied to (x, y) before labeling. The default causes (x, y) to be interpreted as data coordinates. False is a synonym for IdentityTransform; i.e. (x, y) should be interpreted as display coordinates.


Calculate the appropriate label rotation given the linecontour coordinates in screen units, the index of the label location and the label width.
If lc is not None or empty, also break contours and compute inlining.
spacing is the empty space to leave around the label, in pixels.
Both tasks are done together to avoid calculating path lengths multiple times, which is relatively costly.
The method used here involves computing the path length along the contour in pixel coordinates and then looking approximately (label width / 2) away from central point to determine rotation and then to break contour if desired.


Label a contour plot.
Adds labels to line contours in this ContourSet (which inherits from this mixin class).
A list of level values, that should be labeled. The list must be a subset of cs.levels. If not given, all levels are labeled.
Size in points or relative size e.g., 'smaller', 'x-large'. See Text.set_size for accepted string values.
The label colors:
If True the underlying contour is removed where the label is placed.
Space in pixels to leave on each side of label when placing inline.
This spacing will be exact for labels at locations where the contour is straight, less so for labels on curved contours.
How the levels are formatted:
The default is to use a standard ScalarFormatter.
If True, contour labels will be placed manually using mouse clicks. Click the first button near a contour to add a label, click the second button (or potentially both mouse buttons at once) to finish adding labels. The third button can be used to remove the last label added, but only if labels are not inline. Alternatively, the keyboard can be used to select label locations (enter to end label placement, delete or backspace act like the third mouse button, and any other key will select a label location).
manual can also be an iterable object of (x, y) tuples. Contour labels will be created as if mouse is clicked at each (x, y) position.
If True, label rotations will always be plus or minus 90 degrees from level.
If True, ClabelText class (instead of Text) is used to create labels. ClabelText recalculates rotation angles of texts during the drawing time, therefore this can be used if aspect of the axes changes.
zorder of the contour labels.
A list of Text instances for the labels.


[Deprecated] Return x, y, and the index of a label location.
Labels are plotted at a location with the smallest deviation of the contour from a straight line unless there is another label nearby, in which case the next best place on the contour is picked up. If all such candidates are rejected, the beginning of the contour is chosen.
Deprecated since version 3.4.


[Deprecated] Return the width of the label in points.
Deprecated since version 3.5.


Find good place to draw a label (relatively flat part of the contour).


Defaults to removing last label, but any index can be supplied


Return whether a contour is long enough to hold a label.


Set the label properties - color, fontsize, text.


Return whether a label is already near this location.


Bases: matplotlib.cm.ScalarMappable, matplotlib.contour.ContourLabeler
Store a set of contour lines or filled regions.
User-callable method: clabel
A list of floating point numbers indicating the contour levels.
List of all the polygon segments for all the levels. For contour lines len(allsegs) == len(levels), and for filled contour regions len(allsegs) = len(levels)-1. The lists should look like
Optional list of all the polygon vertex kinds (code types), as described and used in Path. This is used to allow multiply- connected paths such as holes within filled polygons. If not None, len(allkinds) == len(allsegs). The lists should look like
If allkinds is not None, usually all polygons for a particular contour level are grouped together so that level0segs = [polygon0] and level0kinds = [polygon0kinds].
Keyword arguments are as described in the docstring of contour.
The Axes object in which the contours are drawn.
The Artists representing the contour. This is a list of PathCollections for both line and filled contours.
The values of the contour levels.
Same as levels for line contours; half-way between levels for filled contours. See ContourSet._process_colors.
Draw contour lines or filled regions, depending on whether keyword arg filled is False (default) or True.
Call signature:
The Axes object to draw on.
A list of floating point numbers indicating the contour levels.
List of all the polygon segments for all the levels. For contour lines len(allsegs) == len(levels), and for filled contour regions len(allsegs) = len(levels)-1. The lists should look like
Optional list of all the polygon vertex kinds (code types), as described and used in Path. This is used to allow multiply- connected paths such as holes within filled polygons. If not None, len(allkinds) == len(allsegs). The lists should look like
If allkinds is not None, usually all polygons for a particular contour level are grouped together so that level0segs = [polygon0] and level0kinds = [polygon0kinds].
Keyword arguments are as described in the docstring of contour.
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
Find the point in the contour plot that is closest to (x, y).
The reference point.
Indices of contour levels to consider. If None (the default), all levels are considered.
If True, measure distance in pixel (screen) space, which is useful for manual contour labeling; else, measure distance in axes space.
The contour that is closest to (x, y).
The index of the Path in contour that is closest to (x, y).
The index of the path segment in segment that is closest to (x, y).
The point in the contour plot that is closest to (x, y).
The squared distance from (xmin, ymin) to (x, y).
Return alpha to be applied to all ContourSet artists.
Return the Transform instance used by this ContourSet.
Return a list of artists and labels suitable for passing through to legend which represent this ContourSet.
The labels have the form "0 < x <= 1" stating the data ranges which the artists represent.
The string used inside the inequality used on the labels.
Function used to format the numbers in the labels.
A list of the artists.
A list of the labels.
Set the alpha blending value for all ContourSet artists. alpha must be between 0 (transparent) and 1 (opaque).


Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.


Find the point in the contour plot that is closest to (x, y).
The reference point.
Indices of contour levels to consider. If None (the default), all levels are considered.
If True, measure distance in pixel (screen) space, which is useful for manual contour labeling; else, measure distance in axes space.
The contour that is closest to (x, y).
The index of the Path in contour that is closest to (x, y).
The index of the path segment in segment that is closest to (x, y).
The point in the contour plot that is closest to (x, y).
The squared distance from (xmin, ymin) to (x, y).


Return alpha to be applied to all ContourSet artists.


Return the Transform instance used by this ContourSet.


Return a list of artists and labels suitable for passing through to legend which represent this ContourSet.
The labels have the form "0 < x <= 1" stating the data ranges which the artists represent.
The string used inside the inequality used on the labels.
Function used to format the numbers in the labels.
A list of the artists.
A list of the labels.


Set the alpha blending value for all ContourSet artists. alpha must be between 0 (transparent) and 1 (opaque).


Bases: matplotlib.contour.ContourSet
Create and store a set of contour lines or filled regions.
This class is typically not instantiated directly by the user but by contour and contourf.
The Axes object in which the contours are drawn.
The Artists representing the contour. This is a list of PathCollections for both line and filled contours.
The values of the contour levels.
Same as levels for line contours; half-way between levels for filled contours. See ContourSet._process_colors.
Draw contour lines or filled regions, depending on whether keyword arg filled is False (default) or True.
Call signature:
The Axes object to draw on.
A list of floating point numbers indicating the contour levels.
List of all the polygon segments for all the levels. For contour lines len(allsegs) == len(levels), and for filled contour regions len(allsegs) = len(levels)-1. The lists should look like
Optional list of all the polygon vertex kinds (code types), as described and used in Path. This is used to allow multiply- connected paths such as holes within filled polygons. If not None, len(allkinds) == len(allsegs). The lists should look like
If allkinds is not None, usually all polygons for a particular contour level are grouped together so that level0segs = [polygon0] and level0kinds = [polygon0kinds].
Keyword arguments are as described in the docstring of contour.


Matplotlib provides sophisticated date plotting capabilities, standing on the shoulders of python datetime and the add-on module dateutil.
By default, Matplotlib uses the units machinery described in units to convert datetime.datetime, and numpy.datetime64 objects when plotted on an x- or y-axis. The user does not need to do anything for dates to be formatted, but dates often have strict formatting needs, so this module provides many axis locators and formatters. A basic example using numpy.datetime64 is:
See also
Matplotlib represents dates using floating point numbers specifying the number of days since a default epoch of 1970-01-01 UTC; for example, 1970-01-01, 06:00 is the floating point number 0.25. The formatters and locators require the use of datetime.datetime objects, so only dates between year 0001 and 9999 can be represented. Microsecond precision is achievable for (approximately) 70 years on either side of the epoch, and 20 microseconds for the rest of the allowable range of dates (year 0001 to 9999). The epoch can be changed at import time via dates.set_epoch or rcParams["dates.epoch"] to other dates if necessary; see Date Precision and Epochs for a discussion.
Note
Before Matplotlib 3.3, the epoch was 0000-12-31 which lost modern microsecond precision and also made the default axis limit of 0 an invalid datetime. In 3.3 the epoch was changed as above. To convert old ordinal floats to the new epoch, users can do:
There are a number of helper functions to convert between datetime objects and Matplotlib dates:
datestr2num
Convert a date string to a datenum using dateutil.parser.parse.
date2num
Convert datetime objects to Matplotlib dates.
num2date
Convert Matplotlib dates to datetime objects.
num2timedelta
Convert number of days to a timedelta object.
drange
Return a sequence of equally spaced Matplotlib dates.
set_epoch
Set the epoch (origin for dates) for datetime calculations.
get_epoch
Get the epoch used by dates.
Note
Like Python's datetime.datetime, Matplotlib uses the Gregorian calendar for all conversions between dates and floating point numbers. This practice is not universal, and calendar differences can cause confusing differences between what Python and Matplotlib give as the number of days since 0001-01-01 and what other software and databases yield. For example, the US Naval Observatory uses a calendar that switches from Julian to Gregorian in October, 1582. Hence, using their calculator, the number of days between 0001-01-01 and 2006-04-01 is 732403, whereas using the Gregorian calendar via the datetime module we find:
All the Matplotlib date converters, tickers and formatters are timezone aware. If no explicit timezone is provided, rcParams["timezone"] (default: 'UTC') is assumed. If you want to use a custom time zone, pass a datetime.tzinfo instance with the tz keyword argument to num2date, Axis.axis_date, and any custom date tickers or locators you create.
A wide range of specific and general purpose date tick locators and formatters are provided in this module. See matplotlib.ticker for general information on tick locators and formatters. These are described below.
The dateutil module provides additional code to handle date ticking, making it easy to place ticks on any kinds of dates. See examples below.
Most of the date tickers can locate single or multiple values. For example:
In addition, most of the constructors take an interval argument:
The rrule locator allows completely general date ticking:
The available date tickers are:
The available date formatters are:
Bases: matplotlib.ticker.Formatter
A Formatter which attempts to figure out the best format to use. This is most useful when used with the AutoDateLocator.
AutoDateFormatter has a .scale dictionary that maps tick scales (the interval in days between one major tick) to format strings; this dictionary defaults to
The formatter uses the format string corresponding to the lowest key in the dictionary that is greater or equal to the current scale. Dictionary entries can be customized:
Custom callables can also be used instead of format strings. The following example shows how to use a custom format function to strip trailing zeros from decimal seconds and adds the date to the first ticklabel:
Autoformat the date labels.
Locator that this axis is using.
Passed to dates.date2num.
The default format to use if none of the values in self.scaled are greater than the unit returned by locator._get_unit().
To enable/disable the use of TeX's math mode for rendering the results of the formatter. If any entries in self.scaled are set as functions, then it is up to the customized function to enable or disable TeX's math mode itself.
Bases: matplotlib.dates.DateLocator
On autoscale, this class picks the best DateLocator to set the view limits and the tick locations.
Mapping of tick frequencies to multiples allowed for that ticking. The default is
where the keys are defined in dateutil.rrule.
The interval is used to specify multiples that are appropriate for the frequency of ticking. For instance, every 7 days is sensible for daily ticks, but for minutes/seconds, 15 or 30 make sense.
When customizing, you should only modify the values for the existing keys. You should not add or delete entries.
Example for forcing ticks every 3 hours:
Ticks timezone.
The minimum number of ticks desired; controls whether ticks occur yearly, monthly, etc.
The maximum number of ticks desired; controls the interval between ticks (ticking every other, every 3, etc.). For fine-grained control, this can be a dictionary mapping individual rrule frequency constants (YEARLY, MONTHLY, etc.) to their own maximum number of ticks. This can be used to keep the number of ticks appropriate to the format chosen in AutoDateFormatter. Any frequency not specified in this dictionary is given a default value.
Whether ticks should be chosen to be multiple of the interval, locking them to 'nicer' locations. For example, this will force the ticks to be at hours 0, 6, 12, 18 when hourly ticking is done at 6 hour intervals.
Pick the best locator based on a distance.
Given the proposed upper and lower extent, adjust the range if it is too close to being singular (i.e. a range of ~0).
Return the values of the located ticks given vmin and vmax.
Note
To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:
Bases: matplotlib.dates.DateConverter
Return the AxisInfo for unit.
unit is a tzinfo instance or None. The axis argument is required but not used.
Bases: matplotlib.ticker.Formatter
A Formatter which attempts to figure out the best format to use for the date, and to make it as compact as possible, but still be complete. This is most useful when used with the AutoDateLocator:
Locator that this axis is using.
Passed to dates.date2num.
Format strings for 6 levels of tick labelling: mostly years, months, days, hours, minutes, and seconds. Strings use the same format codes as strftime. Default is ['%Y', '%b', '%d', '%H:%M', '%H:%M', '%S.%f']
Format strings for tick labels that are "zeros" for a given tick level. For instance, if most ticks are months, ticks around 1 Jan 2005 will be labeled "Dec", "2005", "Feb". The default is ['', '%Y', '%b', '%b-%d', '%H:%M', '%H:%M']
Format strings for the 6 levels that is applied to the "offset" string found on the right side of an x-axis, or top of a y-axis. Combined with the tick labels this should completely specify the date. The default is:
Whether to show the offset or not.
To enable/disable the use of TeX's math mode for rendering the results of the formatter.
See Formatting date ticks using ConciseDateFormatter
(Source code, png, pdf)
Autoformat the date labels. The default format is used to form an initial string, and then redundant elements are removed.
Return a short string version of the tick value.
Defaults to the position-independent long value.
Return the tick labels for all the ticks at once.
Bases: matplotlib.units.ConversionInterface
Converter for datetime.date and datetime.datetime data, or for date/time data represented as it would be converted by date2num.
The 'unit' tag for such data is None or a tzinfo instance.
Return the AxisInfo for unit.
unit is a tzinfo instance or None. The axis argument is required but not used.
If value is not already a number or sequence of numbers, convert it with date2num.
The unit and axis arguments are not used.
Return the tzinfo instance of x or of its first element, or None
Bases: matplotlib.ticker.Formatter
Format a tick (in days since the epoch) with a strftime format string.
strftime format string
Ticks timezone.
To enable/disable the use of TeX's math mode for rendering the results of the formatter.
Bases: matplotlib.ticker.Locator
Determines the tick locations when plotting dates.
This class is subclassed by other Locators and is not meant to be used on its own.
Convert axis data interval to datetime objects.
Given the proposed upper and lower extent, adjust the range if it is too close to being singular (i.e. a range of ~0).
Set time zone info.
Convert the view interval to datetime objects.
Bases: matplotlib.dates.RRuleLocator
Make ticks on occurrences of each day of the month. For example, 1, 15, 30.
Mark every day in bymonthday; bymonthday can be an int or sequence.
Default is to tick every day of the month: bymonthday=range(1, 32).
Bases: matplotlib.dates.RRuleLocator
Make ticks on occurrences of each hour.
Mark every hour in byhour; byhour can be an int or sequence. Default is to tick every hour: byhour=range(24)
interval is the interval between each iteration. For example, if interval=2, mark every second occurrence.
Bases: matplotlib.dates.DateLocator
Make ticks on regular intervals of one or more microsecond(s).
Note
By default, Matplotlib uses a floating point representation of time in days since the epoch, so plotting data with microsecond time resolution does not work well for dates that are far (about 70 years) from the epoch (check with get_epoch).
If you want sub-microsecond resolution time plots, it is strongly recommended to use floating point seconds, not datetime-like time representation.
If you really must use datetime.datetime() or similar and still need microsecond precision, change the time origin via dates.set_epoch to something closer to the dates being plotted. See Date Precision and Epochs.
interval is the interval between each iteration. For example, if interval=2, mark every second microsecond.
[Deprecated]
Deprecated since version 3.5:
[Deprecated]
Deprecated since version 3.5:
Return the values of the located ticks given vmin and vmax.
Note
To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:
Bases: matplotlib.dates.RRuleLocator
Make ticks on occurrences of each minute.
Mark every minute in byminute; byminute can be an int or sequence. Default is to tick every minute: byminute=range(60)
interval is the interval between each iteration. For example, if interval=2, mark every second occurrence.
Bases: matplotlib.dates.RRuleLocator
Make ticks on occurrences of each month, e.g., 1, 3, 12.
Mark every month in bymonth; bymonth can be an int or sequence. Default is range(1, 13), i.e. every month.
interval is the interval between each iteration. For example, if interval=2, mark every second occurrence.
Bases: matplotlib.dates.DateLocator
Return the values of the located ticks given vmin and vmax.
Note
To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:
Bases: matplotlib.dates.RRuleLocator
Make ticks on occurrences of each second.
Mark every second in bysecond; bysecond can be an int or sequence. Default is to tick every second: bysecond = range(60)
interval is the interval between each iteration. For example, if interval=2, mark every second occurrence.
Bases: matplotlib.dates.RRuleLocator
Make ticks on occurrences of each weekday.
Mark every weekday in byweekday; byweekday can be a number or sequence.
Elements of byweekday must be one of MO, TU, WE, TH, FR, SA, SU, the constants from dateutil.rrule, which have been imported into the matplotlib.dates namespace.
interval specifies the number of weeks to skip. For example, interval=2 plots every second week.
Bases: matplotlib.dates.RRuleLocator
Make ticks on a given day of each year that is a multiple of base.
Examples:
Mark years that are multiple of base on a given month and day (default jan 1).
Convert datetime objects to Matplotlib dates.
Number of days since the epoch. See get_epoch for the epoch, which can be changed by rcParams["date.epoch"] (default: '1970-01-01T00:00:00') or set_epoch. If the epoch is "1970-01-01T00:00:00" (default) then noon Jan 1 1970 ("1970-01-01T12:00:00") returns 0.5.
The Gregorian calendar is assumed; this is not universal practice. For details see the module docstring.
Convert a date string to a datenum using dateutil.parser.parse.
The dates to convert.
The default date to use when fields are missing in d.
Return a sequence of equally spaced Matplotlib dates.
The dates start at dstart and reach up to, but not including dend. They are spaced by delta.
The date limits.
Spacing of the dates.
A list floats representing Matplotlib dates.
[Deprecated] Convert UNIX time to days since Matplotlib epoch.
Time in seconds since 1970-01-01.
Time in days since Matplotlib epoch (see get_epoch()).
Deprecated since version 3.5.
Get the epoch used by dates.
String for the epoch (parsable by numpy.datetime64).
Convert Matplotlib dates to datetime objects.
Number of days (fraction part represents hours, minutes, seconds) since the epoch. See get_epoch for the epoch, which can be changed by rcParams["date.epoch"] (default: '1970-01-01T00:00:00') or set_epoch.
Timezone of x.
Dates are returned in timezone tz.
If x is a sequence, a sequence of datetime objects will be returned.
The addition of one here is a historical artifact. Also, note that the Gregorian calendar is assumed; this is not universal practice. For details, see the module docstring.
[Deprecated] Convert days since Matplotlib epoch to UNIX time.
Time in days since Matplotlib epoch (see get_epoch()).
Time in seconds since 1970-01-01.
Deprecated since version 3.5.
Convert number of days to a timedelta object.
If x is a sequence, a sequence of timedelta objects will be returned.
Number of days. The fraction part represents hours, minutes, seconds.
Bases: object
The relativedelta type is designed to be applied to an existing datetime and can replace specific components of that datetime, or represents an interval of time.
It is based on the specification of the excellent work done by M.-A. Lemburg in his mx.DateTime extension. However, notice that this type does NOT implement the same algorithm as his work. Do NOT expect it to behave like mx.DateTime's counterpart.
There are two different ways to build a relativedelta instance. The first one is passing it two date/datetime classes:
The second one is passing it any number of the following keyword arguments:
There are relative and absolute forms of the keyword arguments. The plural is relative, and the singular is absolute. For each argument in the order below, the absolute form is applied first (by setting each attribute to that value) and then the relative form (by adding the value to the attribute).
The order of attributes considered when this relativedelta is added to a datetime is:
Finally, weekday is applied, using the rule described above.
For example
First, the day is set to 1 (the first of the month), then 25 hours are added, to get to the 2nd day and 14th hour, finally the weekday is applied, but since the 2nd is already a Monday there is no effect.
Return a version of this object represented entirely using integer values for the relative attributes.
Returns a dateutil.relativedelta.relativedelta object.
Bases: dateutil.rrule.rrulebase
That's the base of the rrule operation. It accepts all the keywords defined in the RFC as its constructor parameters (except byday, which was renamed to byweekday) and more. The constructor prototype is:
Where freq must be one of YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, or SECONDLY.
Note
Per RFC section 3.3.10, recurrence instances falling on invalid dates and times are ignored rather than coerced:
Recurrence rules may generate recurrence instances with an invalid date (e.g., February 30) or nonexistent local time (e.g., 1:30 AM on a day where the local time is moved forward by an hour at 1:00 AM). Such recurrence instances MUST be ignored and MUST NOT be counted as part of the recurrence set.
This can lead to possibly surprising behavior when, for example, the start date occurs at the end of the month:
Additionally, it supports the following keyword arguments:
count --
If given, this determines how many occurrences will be generated.
Note
As of version 2.5.0, the use of the keyword until in conjunction with count is deprecated, to make sure dateutil is fully compliant with RFC-5545 Sec. 3.3.10. Therefore, until and count must not occur in the same call to rrule.
until --
If given, this must be a datetime instance specifying the upper-bound limit of the recurrence. The last recurrence in the rule is the greatest datetime that is less than or equal to the value specified in the until parameter.
Note
As of version 2.5.0, the use of the keyword until in conjunction with count is deprecated, to make sure dateutil is fully compliant with RFC-5545 Sec. 3.3.10. Therefore, until and count must not occur in the same call to rrule.
Return new rrule with same attributes except for those attributes given new values by whichever keyword arguments are specified.
Set the epoch (origin for dates) for datetime calculations.
The default epoch is rcParams["dates.epoch"] (by default 1970-01-01T00:00).
If microsecond accuracy is desired, the date being plotted needs to be within approximately 70 years of the epoch. Matplotlib internally represents dates as days since the epoch, so floating point dynamic range needs to be within a factor of 2^52.
set_epoch must be called before any dates are converted (i.e. near the import section) or a RuntimeError will be raised.
See also Date Precision and Epochs.
valid UTC date parsable by numpy.datetime64 (do not include timezone).


Bases: matplotlib.ticker.Formatter
A Formatter which attempts to figure out the best format to use. This is most useful when used with the AutoDateLocator.
AutoDateFormatter has a .scale dictionary that maps tick scales (the interval in days between one major tick) to format strings; this dictionary defaults to
The formatter uses the format string corresponding to the lowest key in the dictionary that is greater or equal to the current scale. Dictionary entries can be customized:
Custom callables can also be used instead of format strings. The following example shows how to use a custom format function to strip trailing zeros from decimal seconds and adds the date to the first ticklabel:
Autoformat the date labels.
Locator that this axis is using.
Passed to dates.date2num.
The default format to use if none of the values in self.scaled are greater than the unit returned by locator._get_unit().
To enable/disable the use of TeX's math mode for rendering the results of the formatter. If any entries in self.scaled are set as functions, then it is up to the customized function to enable or disable TeX's math mode itself.


Bases: matplotlib.dates.DateLocator
On autoscale, this class picks the best DateLocator to set the view limits and the tick locations.
Mapping of tick frequencies to multiples allowed for that ticking. The default is
where the keys are defined in dateutil.rrule.
The interval is used to specify multiples that are appropriate for the frequency of ticking. For instance, every 7 days is sensible for daily ticks, but for minutes/seconds, 15 or 30 make sense.
When customizing, you should only modify the values for the existing keys. You should not add or delete entries.
Example for forcing ticks every 3 hours:
Ticks timezone.
The minimum number of ticks desired; controls whether ticks occur yearly, monthly, etc.
The maximum number of ticks desired; controls the interval between ticks (ticking every other, every 3, etc.). For fine-grained control, this can be a dictionary mapping individual rrule frequency constants (YEARLY, MONTHLY, etc.) to their own maximum number of ticks. This can be used to keep the number of ticks appropriate to the format chosen in AutoDateFormatter. Any frequency not specified in this dictionary is given a default value.
Whether ticks should be chosen to be multiple of the interval, locking them to 'nicer' locations. For example, this will force the ticks to be at hours 0, 6, 12, 18 when hourly ticking is done at 6 hour intervals.
Pick the best locator based on a distance.
Given the proposed upper and lower extent, adjust the range if it is too close to being singular (i.e. a range of ~0).
Return the values of the located ticks given vmin and vmax.
Note
To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:


Pick the best locator based on a distance.


Given the proposed upper and lower extent, adjust the range if it is too close to being singular (i.e. a range of ~0).


Return the values of the located ticks given vmin and vmax.
Note
To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:


Bases: matplotlib.dates.DateConverter
Return the AxisInfo for unit.
unit is a tzinfo instance or None. The axis argument is required but not used.


Return the AxisInfo for unit.
unit is a tzinfo instance or None. The axis argument is required but not used.


Bases: matplotlib.ticker.Formatter
A Formatter which attempts to figure out the best format to use for the date, and to make it as compact as possible, but still be complete. This is most useful when used with the AutoDateLocator:
Locator that this axis is using.
Passed to dates.date2num.
Format strings for 6 levels of tick labelling: mostly years, months, days, hours, minutes, and seconds. Strings use the same format codes as strftime. Default is ['%Y', '%b', '%d', '%H:%M', '%H:%M', '%S.%f']
Format strings for tick labels that are "zeros" for a given tick level. For instance, if most ticks are months, ticks around 1 Jan 2005 will be labeled "Dec", "2005", "Feb". The default is ['', '%Y', '%b', '%b-%d', '%H:%M', '%H:%M']
Format strings for the 6 levels that is applied to the "offset" string found on the right side of an x-axis, or top of a y-axis. Combined with the tick labels this should completely specify the date. The default is:
Whether to show the offset or not.
To enable/disable the use of TeX's math mode for rendering the results of the formatter.
See Formatting date ticks using ConciseDateFormatter
(Source code, png, pdf)
Autoformat the date labels. The default format is used to form an initial string, and then redundant elements are removed.
Return a short string version of the tick value.
Defaults to the position-independent long value.
Return the tick labels for all the ticks at once.


Return a short string version of the tick value.
Defaults to the position-independent long value.


Return the tick labels for all the ticks at once.


Convert datetime objects to Matplotlib dates.
Number of days since the epoch. See get_epoch for the epoch, which can be changed by rcParams["date.epoch"] (default: '1970-01-01T00:00:00') or set_epoch. If the epoch is "1970-01-01T00:00:00" (default) then noon Jan 1 1970 ("1970-01-01T12:00:00") returns 0.5.
The Gregorian calendar is assumed; this is not universal practice. For details see the module docstring.


Bases: matplotlib.units.ConversionInterface
Converter for datetime.date and datetime.datetime data, or for date/time data represented as it would be converted by date2num.
The 'unit' tag for such data is None or a tzinfo instance.
Return the AxisInfo for unit.
unit is a tzinfo instance or None. The axis argument is required but not used.
If value is not already a number or sequence of numbers, convert it with date2num.
The unit and axis arguments are not used.
Return the tzinfo instance of x or of its first element, or None


If value is not already a number or sequence of numbers, convert it with date2num.
The unit and axis arguments are not used.


Return the tzinfo instance of x or of its first element, or None


Bases: matplotlib.ticker.Formatter
Format a tick (in days since the epoch) with a strftime format string.
strftime format string
Ticks timezone.
To enable/disable the use of TeX's math mode for rendering the results of the formatter.


Bases: matplotlib.ticker.Locator
Determines the tick locations when plotting dates.
This class is subclassed by other Locators and is not meant to be used on its own.
Convert axis data interval to datetime objects.
Given the proposed upper and lower extent, adjust the range if it is too close to being singular (i.e. a range of ~0).
Set time zone info.
Convert the view interval to datetime objects.


Convert axis data interval to datetime objects.


Convert the view interval to datetime objects.


Convert a date string to a datenum using dateutil.parser.parse.
The dates to convert.
The default date to use when fields are missing in d.


Bases: matplotlib.dates.RRuleLocator
Make ticks on occurrences of each day of the month. For example, 1, 15, 30.
Mark every day in bymonthday; bymonthday can be an int or sequence.
Default is to tick every day of the month: bymonthday=range(1, 32).


Return a sequence of equally spaced Matplotlib dates.
The dates start at dstart and reach up to, but not including dend. They are spaced by delta.
The date limits.
Spacing of the dates.
A list floats representing Matplotlib dates.


[Deprecated] Convert UNIX time to days since Matplotlib epoch.
Time in seconds since 1970-01-01.
Time in days since Matplotlib epoch (see get_epoch()).
Deprecated since version 3.5.


Get the epoch used by dates.
String for the epoch (parsable by numpy.datetime64).


Bases: matplotlib.dates.RRuleLocator
Make ticks on occurrences of each hour.
Mark every hour in byhour; byhour can be an int or sequence. Default is to tick every hour: byhour=range(24)
interval is the interval between each iteration. For example, if interval=2, mark every second occurrence.


Bases: matplotlib.dates.DateLocator
Make ticks on regular intervals of one or more microsecond(s).
Note
By default, Matplotlib uses a floating point representation of time in days since the epoch, so plotting data with microsecond time resolution does not work well for dates that are far (about 70 years) from the epoch (check with get_epoch).
If you want sub-microsecond resolution time plots, it is strongly recommended to use floating point seconds, not datetime-like time representation.
If you really must use datetime.datetime() or similar and still need microsecond precision, change the time origin via dates.set_epoch to something closer to the dates being plotted. See Date Precision and Epochs.
interval is the interval between each iteration. For example, if interval=2, mark every second microsecond.
[Deprecated]
Deprecated since version 3.5:
[Deprecated]
Deprecated since version 3.5:
Return the values of the located ticks given vmin and vmax.
Note
To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:


[Deprecated]
Deprecated since version 3.5:


Return the values of the located ticks given vmin and vmax.
Note
To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:


Bases: matplotlib.dates.RRuleLocator
Make ticks on occurrences of each minute.
Mark every minute in byminute; byminute can be an int or sequence. Default is to tick every minute: byminute=range(60)
interval is the interval between each iteration. For example, if interval=2, mark every second occurrence.


Bases: matplotlib.dates.RRuleLocator
Make ticks on occurrences of each month, e.g., 1, 3, 12.
Mark every month in bymonth; bymonth can be an int or sequence. Default is range(1, 13), i.e. every month.
interval is the interval between each iteration. For example, if interval=2, mark every second occurrence.


Convert Matplotlib dates to datetime objects.
Number of days (fraction part represents hours, minutes, seconds) since the epoch. See get_epoch for the epoch, which can be changed by rcParams["date.epoch"] (default: '1970-01-01T00:00:00') or set_epoch.
Timezone of x.
Dates are returned in timezone tz.
If x is a sequence, a sequence of datetime objects will be returned.
The addition of one here is a historical artifact. Also, note that the Gregorian calendar is assumed; this is not universal practice. For details, see the module docstring.


[Deprecated] Convert days since Matplotlib epoch to UNIX time.
Time in days since Matplotlib epoch (see get_epoch()).
Time in seconds since 1970-01-01.
Deprecated since version 3.5.


Convert number of days to a timedelta object.
If x is a sequence, a sequence of timedelta objects will be returned.
Number of days. The fraction part represents hours, minutes, seconds.


Bases: object
The relativedelta type is designed to be applied to an existing datetime and can replace specific components of that datetime, or represents an interval of time.
It is based on the specification of the excellent work done by M.-A. Lemburg in his mx.DateTime extension. However, notice that this type does NOT implement the same algorithm as his work. Do NOT expect it to behave like mx.DateTime's counterpart.
There are two different ways to build a relativedelta instance. The first one is passing it two date/datetime classes:
The second one is passing it any number of the following keyword arguments:
There are relative and absolute forms of the keyword arguments. The plural is relative, and the singular is absolute. For each argument in the order below, the absolute form is applied first (by setting each attribute to that value) and then the relative form (by adding the value to the attribute).
The order of attributes considered when this relativedelta is added to a datetime is:
Finally, weekday is applied, using the rule described above.
For example
First, the day is set to 1 (the first of the month), then 25 hours are added, to get to the 2nd day and 14th hour, finally the weekday is applied, but since the 2nd is already a Monday there is no effect.
Return a version of this object represented entirely using integer values for the relative attributes.
Returns a dateutil.relativedelta.relativedelta object.


Return a version of this object represented entirely using integer values for the relative attributes.
Returns a dateutil.relativedelta.relativedelta object.