fontName(fontprop)[source]

Select a font based on fontprop and return a name suitable for Op.selectfont. If fontprop is a string, it will be interpreted as the filename of the font.


imageObject(image)[source]

Return name of an image XObject representing the given image.


markerObject(path, trans, fill, stroke, lw, joinstyle, capstyle)[source]

Return name of a marker XObject representing the given path.


newTextnote(text, positionRect=[- 100, - 100, 0, 0])[source]


pathCollectionObject(gc, path, trans, padding, filled, stroked)[source]


staticpathOperations(path, transform, clip=None, simplify=None, sketch=None)[source]


reserveObject(name='')[source]

Reserve an ID for an indirect object. The name is used for debugging in case we forget to print out the object with writeObject.


writeInfoDict()[source]

Write out the info dictionary, checking it for good form


writePath(path, transform, clip=False, sketch=None)[source]


writeTrailer()[source]

Write out the PDF trailer.


writeXref()[source]

Write out the xref table.


classmatplotlib.backends.backend_pdf.PdfPages(filename, keep_empty=True, metadata=None)[source]

Bases: object A multi-page PDF file. Notes In reality PdfPages is a thin wrapper around PdfFile, in order to avoid confusion when using savefig and forgetting the format argument. Examples >>> import matplotlib.pyplot as plt
>>> # Initialize:
>>> with PdfPages('foo.pdf') as pdf:
...     # As many times as you like, create a figure fig and save it:
...     fig = plt.figure()
...     pdf.savefig(fig)
...     # When no figure is specified the current figure is saved
...     pdf.savefig()
 Create a new PdfPages object.  Parameters

filenamestr or path-like or file-like

Plots using PdfPages.savefig will be written to a file at this location. The file is opened at once and any older file with the same name is overwritten.
keep_emptybool, optional

If set to False, then empty pdf files will be deleted automatically when closed.
metadatadict, optional

Information dictionary object (see PDF reference section 10.2.1 'Document Information Dictionary'), e.g.: {'Creator': 'My software', 'Author': 'Me', 'Title': 'Awesome'}. The standard keys are 'Title', 'Author', 'Subject', 'Keywords', 'Creator', 'Producer', 'CreationDate', 'ModDate', and 'Trapped'. Values have been predefined for 'Creator', 'Producer' and 'CreationDate'. They can be removed by setting them to None.       attach_note(text, positionRect=[- 100, - 100, 0, 0])[source]

Add a new text note to the page to be saved next. The optional positionRect specifies the position of the new note on the page. It is outside the page per default to make sure it is invisible on printouts.
   close()[source]

Finalize this object, making the underlying file a complete PDF file.
   get_pagecount()[source]

Return the current number of pages in the multipage pdf file.
   infodict()[source]

Return a modifiable information dictionary object (see PDF reference section 10.2.1 'Document Information Dictionary').
   keep_empty

   savefig(figure=None, **kwargs)[source]

Save a Figure to this file as a new page. Any other keyword arguments are passed to savefig.  Parameters

figureFigure or int, default: the active figure

The figure, or index of the figure, that is saved to the file.


attach_note(text, positionRect=[- 100, - 100, 0, 0])[source]

Add a new text note to the page to be saved next. The optional positionRect specifies the position of the new note on the page. It is outside the page per default to make sure it is invisible on printouts.


close()[source]

Finalize this object, making the underlying file a complete PDF file.


get_pagecount()[source]

Return the current number of pages in the multipage pdf file.


infodict()[source]

Return a modifiable information dictionary object (see PDF reference section 10.2.1 'Document Information Dictionary').


savefig(figure=None, **kwargs)[source]

Save a Figure to this file as a new page. Any other keyword arguments are passed to savefig.  Parameters

figureFigure or int, default: the active figure

The figure, or index of the figure, that is saved to the file.


matplotlib.backends.backend_pdf.pdfRepr(obj)[source]

Map Python objects to PDF syntax.


classmatplotlib.backends.backend_pdf.Reference(id)[source]

Bases: object PDF reference object. Use PdfFile.reserveObject() to create References.   pdfRepr()[source]

   write(contents, file)[source]


classmatplotlib.backends.backend_pdf.RendererPdf(file, image_dpi, height, width)[source]

Bases: matplotlib.backends._backend_pdf_ps.RendererPDFPSBase   check_gc(gc, fillcolor=None)[source]

   draw_gouraud_triangle(gc, points, colors, trans)[source]

Draw a Gouraud-shaded triangle.  Parameters

gcGraphicsContextBase

The graphics context.
points(3, 2) array-like

Array of (x, y) points for the triangle.
colors(3, 4) array-like

RGBA colors for each point of the triangle.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.
   draw_gouraud_triangles(gc, points, colors, trans)[source]

Draw a series of Gouraud triangles.  Parameters

points(N, 3, 2) array-like

Array of N (x, y) points for the triangles.
colors(N, 3, 4) array-like

Array of N RGBA colors for each point of the triangles.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.
   draw_image(gc, x, y, im, transform=None)[source]

Draw an RGBA image.  Parameters

gcGraphicsContextBase

A graphics context with clipping information.
xscalar

The distance in physical units (i.e., dots or pixels) from the left hand side of the canvas.
yscalar

The distance in physical units (i.e., dots or pixels) from the bottom side of the canvas.
im(N, M, 4) array-like of np.uint8

An array of RGBA pixels.
transformmatplotlib.transforms.Affine2DBase

If and only if the concrete backend is written such that option_scale_image() returns True, an affine transformation (i.e., an Affine2DBase) may be passed to draw_image(). The translation vector of the transformation is given in physical units (i.e., dots or pixels). Note that the transformation does not override x and y, and has to be applied before translating the result by x and y (this can be accomplished by adding x and y to the translation vector defined by transform).
   draw_markers(gc, marker_path, marker_trans, path, trans, rgbFace=None)[source]

Draw a marker at each of path's vertices (excluding control points). This provides a fallback implementation of draw_markers that makes multiple calls to draw_path(). Some backends may want to override this method in order to draw the marker only once and reuse it multiple times.  Parameters

gcGraphicsContextBase

The graphics context.
marker_transmatplotlib.transforms.Transform

An affine transform applied to the marker.
transmatplotlib.transforms.Transform

An affine transform applied to the path.
   draw_mathtext(gc, x, y, s, prop, angle)[source]

   draw_path(gc, path, transform, rgbFace=None)[source]

Draw a Path instance using the given affine transform.
   draw_path_collection(gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls, offset_position)[source]

Draw a collection of paths selecting drawing properties from the lists facecolors, edgecolors, linewidths, linestyles and antialiaseds. offsets is a list of offsets to apply to each of the paths. The offsets in offsets are first transformed by offsetTrans before being applied. offset_position is unused now, but the argument is kept for backwards compatibility. This provides a fallback implementation of draw_path_collection() that makes multiple calls to draw_path(). Some backends may want to override this in order to render each set of path data only once, and then reference that path multiple times with the different offsets, colors, styles etc. The generator methods _iter_collection_raw_paths() and _iter_collection() are provided to help with (and standardize) the implementation across backends. It is highly recommended to use those generators, so that changes to the behavior of draw_path_collection() can be made globally.
   draw_tex(gc, x, y, s, prop, angle, *, mtext=None)[source]

   draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[source]

Draw the text instance.  Parameters

gcGraphicsContextBase

The graphics context.
xfloat

The x location of the text in display coords.
yfloat

The y location of the text baseline in display coords.
sstr

The text string.
propmatplotlib.font_manager.FontProperties

The font properties.
anglefloat

The rotation angle in degrees anti-clockwise.
mtextmatplotlib.text.Text

The original text object to be rendered.     Notes Note for backend implementers: When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work properly), it helps to change the line in text.py: if 0: bbox_artist(self, renderer)
 to if 1, and then the actual bounding box will be plotted along with your text.
   encode_string(s, fonttype)[source]

   finalize()[source]

   get_image_magnification()[source]

Get the factor by which to magnify images passed to draw_image(). Allows a backend to have images at a different resolution to other artists.
   propertymathtext_parser[source]

   new_gc()[source]

Return an instance of a GraphicsContextBase.


draw_gouraud_triangle(gc, points, colors, trans)[source]

Draw a Gouraud-shaded triangle.  Parameters

gcGraphicsContextBase

The graphics context.
points(3, 2) array-like

Array of (x, y) points for the triangle.
colors(3, 4) array-like

RGBA colors for each point of the triangle.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.


draw_gouraud_triangles(gc, points, colors, trans)[source]

Draw a series of Gouraud triangles.  Parameters

points(N, 3, 2) array-like

Array of N (x, y) points for the triangles.
colors(N, 3, 4) array-like

Array of N RGBA colors for each point of the triangles.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.


draw_image(gc, x, y, im, transform=None)[source]

Draw an RGBA image.  Parameters

gcGraphicsContextBase

A graphics context with clipping information.
xscalar

The distance in physical units (i.e., dots or pixels) from the left hand side of the canvas.
yscalar

The distance in physical units (i.e., dots or pixels) from the bottom side of the canvas.
im(N, M, 4) array-like of np.uint8

An array of RGBA pixels.
transformmatplotlib.transforms.Affine2DBase

If and only if the concrete backend is written such that option_scale_image() returns True, an affine transformation (i.e., an Affine2DBase) may be passed to draw_image(). The translation vector of the transformation is given in physical units (i.e., dots or pixels). Note that the transformation does not override x and y, and has to be applied before translating the result by x and y (this can be accomplished by adding x and y to the translation vector defined by transform).


draw_markers(gc, marker_path, marker_trans, path, trans, rgbFace=None)[source]

Draw a marker at each of path's vertices (excluding control points). This provides a fallback implementation of draw_markers that makes multiple calls to draw_path(). Some backends may want to override this method in order to draw the marker only once and reuse it multiple times.  Parameters

gcGraphicsContextBase

The graphics context.
marker_transmatplotlib.transforms.Transform

An affine transform applied to the marker.
transmatplotlib.transforms.Transform

An affine transform applied to the path.


draw_mathtext(gc, x, y, s, prop, angle)[source]


draw_path(gc, path, transform, rgbFace=None)[source]

Draw a Path instance using the given affine transform.


draw_path_collection(gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls, offset_position)[source]

Draw a collection of paths selecting drawing properties from the lists facecolors, edgecolors, linewidths, linestyles and antialiaseds. offsets is a list of offsets to apply to each of the paths. The offsets in offsets are first transformed by offsetTrans before being applied. offset_position is unused now, but the argument is kept for backwards compatibility. This provides a fallback implementation of draw_path_collection() that makes multiple calls to draw_path(). Some backends may want to override this in order to render each set of path data only once, and then reference that path multiple times with the different offsets, colors, styles etc. The generator methods _iter_collection_raw_paths() and _iter_collection() are provided to help with (and standardize) the implementation across backends. It is highly recommended to use those generators, so that changes to the behavior of draw_path_collection() can be made globally.


draw_tex(gc, x, y, s, prop, angle, *, mtext=None)[source]


draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[source]

Draw the text instance.  Parameters

gcGraphicsContextBase

The graphics context.
xfloat

The x location of the text in display coords.
yfloat

The y location of the text baseline in display coords.
sstr

The text string.
propmatplotlib.font_manager.FontProperties

The font properties.
anglefloat

The rotation angle in degrees anti-clockwise.
mtextmatplotlib.text.Text

The original text object to be rendered.     Notes Note for backend implementers: When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work properly), it helps to change the line in text.py: if 0: bbox_artist(self, renderer)
 to if 1, and then the actual bounding box will be plotted along with your text.


get_image_magnification()[source]

Get the factor by which to magnify images passed to draw_image(). Allows a backend to have images at a different resolution to other artists.


new_gc()[source]

Return an instance of a GraphicsContextBase.


classmatplotlib.backends.backend_pdf.Stream(id, len, file, extra=None, png=None)[source]

Bases: object PDF stream object. This has no pdfRepr method. Instead, call begin(), then output the contents of the stream by calling write(), and finally call end().  Parameters

idint

Object id of the stream.
lenReference or None

An unused Reference object for the length of the stream; None means to use a memory buffer so the length can be inlined.
filePdfFile

The underlying object to write the stream to.
extradict from Name to anything, or None

Extra key-value pairs to include in the stream header.
pngdict or None

If the data is already png encoded, the decode parameters.       compressobj

   end()[source]

Finalize stream.
   extra

   file

   id

   len

   pdfFile

   pos

   write(data)[source]

Write some data on the stream.


write(data)[source]

Write some data on the stream.


classmatplotlib.backends.backend_pdf.Verbatim(x)[source]

Bases: object Store verbatim PDF command content for later inclusion in the stream.   pdfRepr()[source]


matplotlib.backends.backend_pgf.common_texification(text)[source]

Do some necessary and/or useful substitutions for texts to be included in LaTeX documents. This distinguishes text-mode and math-mode by replacing the math separator $ with \(\displaystyle %s\). Escaped math separators (\$) are ignored. The following characters are escaped in text segments: _^$%


matplotlib.backends.backend_pgf.FigureCanvas[source]

alias of matplotlib.backends.backend_pgf.FigureCanvasPgf


classmatplotlib.backends.backend_pgf.FigureCanvasPgf(figure=None)[source]

Bases: matplotlib.backend_bases.FigureCanvasBase   draw()[source]

Render the Figure. It is important that this method actually walk the artist tree even if not output is produced because this will trigger deferred work (like computing limits auto-limits and tick values) that users may want access to before saving to disk.
   filetypes={'pdf': 'LaTeX compiled PGF picture', 'pgf': 'LaTeX PGF picture', 'png': 'Portable Network Graphics'}

   get_default_filetype()[source]

Return the default savefig file format as specified in rcParams["savefig.format"] (default: 'png'). The returned string does not include a period. This method is overridden in backends that only support a single file type.
   get_renderer()[source]

   print_pdf(fname_or_fh, *, metadata=None, **kwargs)[source]

Use LaTeX to compile a pgf generated figure to pdf.
   print_pgf(fname_or_fh, **kwargs)[source]

Output pgf macros for drawing the figure so it can be included and rendered in latex documents.
   print_png(fname_or_fh, **kwargs)[source]

Use LaTeX to compile a pgf figure to pdf and convert it to png.


draw()[source]

Render the Figure. It is important that this method actually walk the artist tree even if not output is produced because this will trigger deferred work (like computing limits auto-limits and tick values) that users may want access to before saving to disk.


filetypes={'pdf': 'LaTeX compiled PGF picture', 'pgf': 'LaTeX PGF picture', 'png': 'Portable Network Graphics'}


get_default_filetype()[source]

Return the default savefig file format as specified in rcParams["savefig.format"] (default: 'png'). The returned string does not include a period. This method is overridden in backends that only support a single file type.


print_pdf(fname_or_fh, *, metadata=None, **kwargs)[source]

Use LaTeX to compile a pgf generated figure to pdf.


print_pgf(fname_or_fh, **kwargs)[source]

Output pgf macros for drawing the figure so it can be included and rendered in latex documents.


print_png(fname_or_fh, **kwargs)[source]

Use LaTeX to compile a pgf figure to pdf and convert it to png.


matplotlib.backends.backend_pgf.get_fontspec()[source]

Build fontspec preamble from rc.


matplotlib.backends.backend_pgf.get_preamble()[source]

Get LaTeX preamble from rc.


exceptionmatplotlib.backends.backend_pgf.LatexError(message, latex_output='')[source]

Bases: Exception


classmatplotlib.backends.backend_pgf.LatexManager[source]

Bases: object The LatexManager opens an instance of the LaTeX application for determining the metrics of text elements. The LaTeX environment can be modified by setting fonts and/or a custom preamble in rcParams.   get_width_height_descent(text, prop)[source]

Get the width, total height, and descent (in TeX points) for a text typeset by the current LaTeX environment.
   propertystr_cache[source]


get_width_height_descent(text, prop)[source]

Get the width, total height, and descent (in TeX points) for a text typeset by the current LaTeX environment.


matplotlib.backends.backend_pgf.make_pdf_to_png_converter()[source]

Return a function that converts a pdf file to a png file.


classmatplotlib.backends.backend_pgf.PdfPages(filename, *, keep_empty=True, metadata=None)[source]

Bases: object A multi-page PDF file using the pgf backend Examples >>> import matplotlib.pyplot as plt
>>> # Initialize:
>>> with PdfPages('foo.pdf') as pdf:
...     # As many times as you like, create a figure fig and save it:
...     fig = plt.figure()
...     pdf.savefig(fig)
...     # When no figure is specified the current figure is saved
...     pdf.savefig()
 Create a new PdfPages object.  Parameters

filenamestr or path-like

Plots using PdfPages.savefig will be written to a file at this location. Any older file with the same name is overwritten.
keep_emptybool, default: True

If set to False, then empty pdf files will be deleted automatically when closed.
metadatadict, optional

Information dictionary object (see PDF reference section 10.2.1 'Document Information Dictionary'), e.g.: {'Creator': 'My software', 'Author': 'Me', 'Title': 'Awesome'}. The standard keys are 'Title', 'Author', 'Subject', 'Keywords', 'Creator', 'Producer', 'CreationDate', 'ModDate', and 'Trapped'. Values have been predefined for 'Creator', 'Producer' and 'CreationDate'. They can be removed by setting them to None. Note that some versions of LaTeX engines may ignore the 'Producer' key and set it to themselves.       close()[source]

Finalize this object, running LaTeX in a temporary directory and moving the final pdf file to filename.
   get_pagecount()[source]

Return the current number of pages in the multipage pdf file.
   keep_empty

   savefig(figure=None, **kwargs)[source]

Save a Figure to this file as a new page. Any other keyword arguments are passed to savefig.  Parameters

figureFigure or int, default: the active figure

The figure, or index of the figure, that is saved to the file.


close()[source]

Finalize this object, running LaTeX in a temporary directory and moving the final pdf file to filename.


get_pagecount()[source]

Return the current number of pages in the multipage pdf file.


savefig(figure=None, **kwargs)[source]

Save a Figure to this file as a new page. Any other keyword arguments are passed to savefig.  Parameters

figureFigure or int, default: the active figure

The figure, or index of the figure, that is saved to the file.


classmatplotlib.backends.backend_pgf.RendererPgf(figure, fh)[source]

Bases: matplotlib.backend_bases.RendererBase Create a new PGF renderer that translates any drawing instruction into text commands to be interpreted in a latex pgfpicture environment.  Attributes

figurematplotlib.figure.Figure

Matplotlib figure to initialize height, width and dpi from.
fhfile-like

File handle for the output of the drawing commands.       draw_image(gc, x, y, im, transform=None)[source]

Draw an RGBA image.  Parameters

gcGraphicsContextBase

A graphics context with clipping information.
xscalar

The distance in physical units (i.e., dots or pixels) from the left hand side of the canvas.
yscalar

The distance in physical units (i.e., dots or pixels) from the bottom side of the canvas.
im(N, M, 4) array-like of np.uint8

An array of RGBA pixels.
transformmatplotlib.transforms.Affine2DBase

If and only if the concrete backend is written such that option_scale_image() returns True, an affine transformation (i.e., an Affine2DBase) may be passed to draw_image(). The translation vector of the transformation is given in physical units (i.e., dots or pixels). Note that the transformation does not override x and y, and has to be applied before translating the result by x and y (this can be accomplished by adding x and y to the translation vector defined by transform).
   draw_markers(gc, marker_path, marker_trans, path, trans, rgbFace=None)[source]

Draw a marker at each of path's vertices (excluding control points). This provides a fallback implementation of draw_markers that makes multiple calls to draw_path(). Some backends may want to override this method in order to draw the marker only once and reuse it multiple times.  Parameters

gcGraphicsContextBase

The graphics context.
marker_transmatplotlib.transforms.Transform

An affine transform applied to the marker.
transmatplotlib.transforms.Transform

An affine transform applied to the path.
   draw_path(gc, path, transform, rgbFace=None)[source]

Draw a Path instance using the given affine transform.
   draw_tex(gc, x, y, s, prop, angle, ismath='TeX', mtext=None)[source]

   draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[source]

Draw the text instance.  Parameters

gcGraphicsContextBase

The graphics context.
xfloat

The x location of the text in display coords.
yfloat

The y location of the text baseline in display coords.
sstr

The text string.
propmatplotlib.font_manager.FontProperties

The font properties.
anglefloat

The rotation angle in degrees anti-clockwise.
mtextmatplotlib.text.Text

The original text object to be rendered.     Notes Note for backend implementers: When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work properly), it helps to change the line in text.py: if 0: bbox_artist(self, renderer)
 to if 1, and then the actual bounding box will be plotted along with your text.
   flipy()[source]

Return whether y values increase from top to bottom. Note that this only affects drawing of texts and images.
   get_canvas_width_height()[source]

Return the canvas width and height in display coords.
   get_text_width_height_descent(s, prop, ismath)[source]

Get the width, height, and descent (offset from the bottom to the baseline), in display coords, of the string s with FontProperties prop.
   option_image_nocomposite()[source]

Return whether image composition by Matplotlib should be skipped. Raster backends should usually return False (letting the C-level rasterizer take care of image composition); vector backends should usually return not rcParams["image.composite_image"].
   option_scale_image()[source]

Return whether arbitrary affine transformations in draw_image() are supported (True for most vector backends).
   points_to_pixels(points)[source]

Convert points to display units. You need to override this function (unless your backend doesn't have a dpi, e.g., postscript or svg). Some imaging systems assume some value for pixels per inch: points to pixels = points * pixels_per_inch/72 * dpi/72
  Parameters

pointsfloat or array-like

a float or a numpy array of float    Returns
 Points converted to pixels


draw_image(gc, x, y, im, transform=None)[source]

Draw an RGBA image.  Parameters

gcGraphicsContextBase

A graphics context with clipping information.
xscalar

The distance in physical units (i.e., dots or pixels) from the left hand side of the canvas.
yscalar

The distance in physical units (i.e., dots or pixels) from the bottom side of the canvas.
im(N, M, 4) array-like of np.uint8

An array of RGBA pixels.
transformmatplotlib.transforms.Affine2DBase

If and only if the concrete backend is written such that option_scale_image() returns True, an affine transformation (i.e., an Affine2DBase) may be passed to draw_image(). The translation vector of the transformation is given in physical units (i.e., dots or pixels). Note that the transformation does not override x and y, and has to be applied before translating the result by x and y (this can be accomplished by adding x and y to the translation vector defined by transform).


draw_markers(gc, marker_path, marker_trans, path, trans, rgbFace=None)[source]

Draw a marker at each of path's vertices (excluding control points). This provides a fallback implementation of draw_markers that makes multiple calls to draw_path(). Some backends may want to override this method in order to draw the marker only once and reuse it multiple times.  Parameters

gcGraphicsContextBase

The graphics context.
marker_transmatplotlib.transforms.Transform

An affine transform applied to the marker.
transmatplotlib.transforms.Transform

An affine transform applied to the path.


draw_path(gc, path, transform, rgbFace=None)[source]

Draw a Path instance using the given affine transform.


draw_tex(gc, x, y, s, prop, angle, ismath='TeX', mtext=None)[source]


draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[source]

Draw the text instance.  Parameters

gcGraphicsContextBase

The graphics context.
xfloat

The x location of the text in display coords.
yfloat

The y location of the text baseline in display coords.
sstr

The text string.
propmatplotlib.font_manager.FontProperties

The font properties.
anglefloat

The rotation angle in degrees anti-clockwise.
mtextmatplotlib.text.Text

The original text object to be rendered.     Notes Note for backend implementers: When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work properly), it helps to change the line in text.py: if 0: bbox_artist(self, renderer)
 to if 1, and then the actual bounding box will be plotted along with your text.


flipy()[source]

Return whether y values increase from top to bottom. Note that this only affects drawing of texts and images.


get_canvas_width_height()[source]

Return the canvas width and height in display coords.


get_text_width_height_descent(s, prop, ismath)[source]

Get the width, height, and descent (offset from the bottom to the baseline), in display coords, of the string s with FontProperties prop.


option_image_nocomposite()[source]

Return whether image composition by Matplotlib should be skipped. Raster backends should usually return False (letting the C-level rasterizer take care of image composition); vector backends should usually return not rcParams["image.composite_image"].


option_scale_image()[source]

Return whether arbitrary affine transformations in draw_image() are supported (True for most vector backends).


points_to_pixels(points)[source]

Convert points to display units. You need to override this function (unless your backend doesn't have a dpi, e.g., postscript or svg). Some imaging systems assume some value for pixels per inch: points to pixels = points * pixels_per_inch/72 * dpi/72
  Parameters

pointsfloat or array-like

a float or a numpy array of float    Returns
 Points converted to pixels


classmatplotlib.backends.backend_pgf.TmpDirCleaner(*args, **kwargs)[source]

Bases: object [Deprecated] Notes  Deprecated since version 3.4:     staticadd(tmpdir)[source]

[Deprecated] Notes  Deprecated since version 3.4:
   staticcleanup_remaining_tmpdirs()[source]

[Deprecated] Notes  Deprecated since version 3.4:
   remaining_tmpdirs={}


staticadd(tmpdir)[source]

[Deprecated] Notes  Deprecated since version 3.4:


staticcleanup_remaining_tmpdirs()[source]

[Deprecated] Notes  Deprecated since version 3.4:


matplotlib.backends.backend_ps.convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble, paper_width, paper_height, orientation)[source]

When we want to use the LaTeX backend with postscript, we write PSFrag tags to a temporary postscript file, each one marking a position for LaTeX to render some text. convert_psfrags generates a LaTeX document containing the commands to convert those tags to text. LaTeX/dvips produces the postscript file that includes the actual text.


matplotlib.backends.backend_ps.FigureCanvas[source]

alias of matplotlib.backends.backend_ps.FigureCanvasPS


classmatplotlib.backends.backend_ps.FigureCanvasPS(figure=None)[source]

Bases: matplotlib.backend_bases.FigureCanvasBase   draw()[source]

Render the Figure. It is important that this method actually walk the artist tree even if not output is produced because this will trigger deferred work (like computing limits auto-limits and tick values) that users may want access to before saving to disk.
   filetypes={'eps': 'Encapsulated Postscript', 'ps': 'Postscript'}

   fixed_dpi=72

   get_default_filetype()[source]

Return the default savefig file format as specified in rcParams["savefig.format"] (default: 'png'). The returned string does not include a period. This method is overridden in backends that only support a single file type.
   print_eps(outfile, *args, **kwargs)[source]

   print_ps(outfile, *args, **kwargs)[source]


draw()[source]

Render the Figure. It is important that this method actually walk the artist tree even if not output is produced because this will trigger deferred work (like computing limits auto-limits and tick values) that users may want access to before saving to disk.


filetypes={'eps': 'Encapsulated Postscript', 'ps': 'Postscript'}


get_default_filetype()[source]

Return the default savefig file format as specified in rcParams["savefig.format"] (default: 'png'). The returned string does not include a period. This method is overridden in backends that only support a single file type.


matplotlib.backends.backend_ps.get_bbox_header(lbrt, rotated=False)[source]

Return a postscript header string for the given bbox lbrt=(l, b, r, t). Optionally, return rotate command.


classmatplotlib.backends.backend_ps.GraphicsContextPS[source]

Bases: matplotlib.backend_bases.GraphicsContextBase [Deprecated] Notes  Deprecated since version 3.4:     get_capstyle()[source]

Return the CapStyle.
   get_joinstyle()[source]

Return the JoinStyle.


get_capstyle()[source]

Return the CapStyle.


get_joinstyle()[source]

Return the JoinStyle.


matplotlib.backends.backend_ps.gs_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False)[source]

Use ghostscript's pswrite or epswrite device to distill a file. This yields smaller files without illegal encapsulated postscript operators. The output is low-level, converting text to outlines.


classmatplotlib.backends.backend_ps.PsBackendHelper[source]

Bases: object


matplotlib.backends.backend_ps.pstoeps(tmpfile, bbox=None, rotated=False)[source]

Convert the postscript to encapsulated postscript. The bbox of the eps file will be replaced with the given bbox argument. If None, original bbox will be used.


matplotlib.backends.backend_ps.quote_ps_string(s)[source]

Quote dangerous characters of S for use in a PostScript string constant.


classmatplotlib.backends.backend_ps.RendererPS(width, height, pswriter, imagedpi=72)[source]

Bases: matplotlib.backends._backend_pdf_ps.RendererPDFPSBase The renderer handles all the drawing primitives using a graphics context instance that controls the colors/styles.   create_hatch(hatch)[source]

   draw_gouraud_triangle(gc, points, colors, trans)[source]

Draw a Gouraud-shaded triangle.  Parameters

gcGraphicsContextBase

The graphics context.
points(3, 2) array-like

Array of (x, y) points for the triangle.
colors(3, 4) array-like

RGBA colors for each point of the triangle.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.
   draw_gouraud_triangles(gc, points, colors, trans)[source]

Draw a series of Gouraud triangles.  Parameters

points(N, 3, 2) array-like

Array of N (x, y) points for the triangles.
colors(N, 3, 4) array-like

Array of N RGBA colors for each point of the triangles.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.
   draw_image(gc, x, y, im, transform=None)[source]

Draw an RGBA image.  Parameters

gcGraphicsContextBase

A graphics context with clipping information.
xscalar

The distance in physical units (i.e., dots or pixels) from the left hand side of the canvas.
yscalar

The distance in physical units (i.e., dots or pixels) from the bottom side of the canvas.
im(N, M, 4) array-like of np.uint8

An array of RGBA pixels.
transformmatplotlib.transforms.Affine2DBase

If and only if the concrete backend is written such that option_scale_image() returns True, an affine transformation (i.e., an Affine2DBase) may be passed to draw_image(). The translation vector of the transformation is given in physical units (i.e., dots or pixels). Note that the transformation does not override x and y, and has to be applied before translating the result by x and y (this can be accomplished by adding x and y to the translation vector defined by transform).
   draw_markers(gc, marker_path, marker_trans, path, trans, rgbFace=None)[source]

Draw a marker at each of path's vertices (excluding control points). This provides a fallback implementation of draw_markers that makes multiple calls to draw_path(). Some backends may want to override this method in order to draw the marker only once and reuse it multiple times.  Parameters

gcGraphicsContextBase

The graphics context.
marker_transmatplotlib.transforms.Transform

An affine transform applied to the marker.
transmatplotlib.transforms.Transform

An affine transform applied to the path.
   draw_mathtext(gc, x, y, s, prop, angle)[source]

Draw the math text using matplotlib.mathtext.
   draw_path(gc, path, transform, rgbFace=None)[source]

Draw a Path instance using the given affine transform.
   draw_path_collection(gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls, offset_position)[source]

Draw a collection of paths selecting drawing properties from the lists facecolors, edgecolors, linewidths, linestyles and antialiaseds. offsets is a list of offsets to apply to each of the paths. The offsets in offsets are first transformed by offsetTrans before being applied. offset_position is unused now, but the argument is kept for backwards compatibility. This provides a fallback implementation of draw_path_collection() that makes multiple calls to draw_path(). Some backends may want to override this in order to render each set of path data only once, and then reference that path multiple times with the different offsets, colors, styles etc. The generator methods _iter_collection_raw_paths() and _iter_collection() are provided to help with (and standardize) the implementation across backends. It is highly recommended to use those generators, so that changes to the behavior of draw_path_collection() can be made globally.
   draw_tex(gc, x, y, s, prop, angle, *, mtext=None)[source]

   draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[source]

Draw the text instance.  Parameters

gcGraphicsContextBase

The graphics context.
xfloat

The x location of the text in display coords.
yfloat

The y location of the text baseline in display coords.
sstr

The text string.
propmatplotlib.font_manager.FontProperties

The font properties.
anglefloat

The rotation angle in degrees anti-clockwise.
mtextmatplotlib.text.Text

The original text object to be rendered.     Notes Note for backend implementers: When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work properly), it helps to change the line in text.py: if 0: bbox_artist(self, renderer)
 to if 1, and then the actual bounding box will be plotted along with your text.
   get_image_magnification()[source]

Get the factor by which to magnify images passed to draw_image. Allows a backend to have images at a different resolution to other artists.
   propertymathtext_parser[source]

   set_color(r, g, b, store=True)[source]

   set_font(fontname, fontsize, store=True)[source]

   set_linecap(linecap, store=True)[source]

   set_linedash(offset, seq, store=True)[source]

   set_linejoin(linejoin, store=True)[source]

   set_linewidth(linewidth, store=True)[source]


draw_gouraud_triangle(gc, points, colors, trans)[source]

Draw a Gouraud-shaded triangle.  Parameters

gcGraphicsContextBase

The graphics context.
points(3, 2) array-like

Array of (x, y) points for the triangle.
colors(3, 4) array-like

RGBA colors for each point of the triangle.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.


draw_gouraud_triangles(gc, points, colors, trans)[source]

Draw a series of Gouraud triangles.  Parameters

points(N, 3, 2) array-like

Array of N (x, y) points for the triangles.
colors(N, 3, 4) array-like

Array of N RGBA colors for each point of the triangles.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.


draw_image(gc, x, y, im, transform=None)[source]

Draw an RGBA image.  Parameters

gcGraphicsContextBase

A graphics context with clipping information.
xscalar

The distance in physical units (i.e., dots or pixels) from the left hand side of the canvas.
yscalar

The distance in physical units (i.e., dots or pixels) from the bottom side of the canvas.
im(N, M, 4) array-like of np.uint8

An array of RGBA pixels.
transformmatplotlib.transforms.Affine2DBase

If and only if the concrete backend is written such that option_scale_image() returns True, an affine transformation (i.e., an Affine2DBase) may be passed to draw_image(). The translation vector of the transformation is given in physical units (i.e., dots or pixels). Note that the transformation does not override x and y, and has to be applied before translating the result by x and y (this can be accomplished by adding x and y to the translation vector defined by transform).


draw_markers(gc, marker_path, marker_trans, path, trans, rgbFace=None)[source]

Draw a marker at each of path's vertices (excluding control points). This provides a fallback implementation of draw_markers that makes multiple calls to draw_path(). Some backends may want to override this method in order to draw the marker only once and reuse it multiple times.  Parameters

gcGraphicsContextBase

The graphics context.
marker_transmatplotlib.transforms.Transform

An affine transform applied to the marker.
transmatplotlib.transforms.Transform

An affine transform applied to the path.


draw_mathtext(gc, x, y, s, prop, angle)[source]

Draw the math text using matplotlib.mathtext.


draw_path(gc, path, transform, rgbFace=None)[source]

Draw a Path instance using the given affine transform.


draw_path_collection(gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls, offset_position)[source]

Draw a collection of paths selecting drawing properties from the lists facecolors, edgecolors, linewidths, linestyles and antialiaseds. offsets is a list of offsets to apply to each of the paths. The offsets in offsets are first transformed by offsetTrans before being applied. offset_position is unused now, but the argument is kept for backwards compatibility. This provides a fallback implementation of draw_path_collection() that makes multiple calls to draw_path(). Some backends may want to override this in order to render each set of path data only once, and then reference that path multiple times with the different offsets, colors, styles etc. The generator methods _iter_collection_raw_paths() and _iter_collection() are provided to help with (and standardize) the implementation across backends. It is highly recommended to use those generators, so that changes to the behavior of draw_path_collection() can be made globally.


draw_tex(gc, x, y, s, prop, angle, *, mtext=None)[source]


draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[source]

Draw the text instance.  Parameters

gcGraphicsContextBase

The graphics context.
xfloat

The x location of the text in display coords.
yfloat

The y location of the text baseline in display coords.
sstr

The text string.
propmatplotlib.font_manager.FontProperties

The font properties.
anglefloat

The rotation angle in degrees anti-clockwise.
mtextmatplotlib.text.Text

The original text object to be rendered.     Notes Note for backend implementers: When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work properly), it helps to change the line in text.py: if 0: bbox_artist(self, renderer)
 to if 1, and then the actual bounding box will be plotted along with your text.


get_image_magnification()[source]

Get the factor by which to magnify images passed to draw_image. Allows a backend to have images at a different resolution to other artists.


matplotlib.backends.backend_ps.xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False)[source]

Use ghostscript's ps2pdf and xpdf's/poppler's pdftops to distill a file. This yields smaller files without illegal encapsulated postscript operators. This distiller is preferred, generating high-level postscript output that treats text as text.


matplotlib.backends.backend_svg.FigureCanvas[source]

alias of matplotlib.backends.backend_svg.FigureCanvasSVG


classmatplotlib.backends.backend_svg.FigureCanvasSVG(figure=None)[source]

Bases: matplotlib.backend_bases.FigureCanvasBase   draw()[source]

Render the Figure. It is important that this method actually walk the artist tree even if not output is produced because this will trigger deferred work (like computing limits auto-limits and tick values) that users may want access to before saving to disk.
   filetypes={'svg': 'Scalable Vector Graphics', 'svgz': 'Scalable Vector Graphics'}

   fixed_dpi=72

   get_default_filetype()[source]

Return the default savefig file format as specified in rcParams["savefig.format"] (default: 'png'). The returned string does not include a period. This method is overridden in backends that only support a single file type.
   print_svg(filename, *args, dpi=<deprecated parameter>, bbox_inches_restore=None, metadata=None)[source]

 Parameters

filenamestr or path-like or file-like

Output target; if a string, a file will be opened for writing.
metadatadict[str, Any], optional

Metadata in the SVG file defined as key-value pairs of strings, datetimes, or lists of strings, e.g., {'Creator': 'My software',
'Contributor': ['Me', 'My Friend'], 'Title': 'Awesome'}. The standard keys and their value types are:
str: 'Coverage', 'Description', 'Format', 'Identifier', 'Language', 'Relation', 'Source', 'Title', and 'Type'.
str or list of str: 'Contributor', 'Creator', 'Keywords', 'Publisher', and 'Rights'.
str, date, datetime, or tuple of same: 'Date'. If a non-str, then it will be formatted as ISO 8601.  Values have been predefined for 'Creator', 'Date', 'Format', and 'Type'. They can be removed by setting them to None. Information is encoded as Dublin Core Metadata.
   print_svgz(filename, *args, **kwargs)[source]


draw()[source]

Render the Figure. It is important that this method actually walk the artist tree even if not output is produced because this will trigger deferred work (like computing limits auto-limits and tick values) that users may want access to before saving to disk.


filetypes={'svg': 'Scalable Vector Graphics', 'svgz': 'Scalable Vector Graphics'}


get_default_filetype()[source]

Return the default savefig file format as specified in rcParams["savefig.format"] (default: 'png'). The returned string does not include a period. This method is overridden in backends that only support a single file type.


print_svg(filename, *args, dpi=<deprecated parameter>, bbox_inches_restore=None, metadata=None)[source]

 Parameters

filenamestr or path-like or file-like

Output target; if a string, a file will be opened for writing.
metadatadict[str, Any], optional

Metadata in the SVG file defined as key-value pairs of strings, datetimes, or lists of strings, e.g., {'Creator': 'My software',
'Contributor': ['Me', 'My Friend'], 'Title': 'Awesome'}. The standard keys and their value types are:
str: 'Coverage', 'Description', 'Format', 'Identifier', 'Language', 'Relation', 'Source', 'Title', and 'Type'.
str or list of str: 'Contributor', 'Creator', 'Keywords', 'Publisher', and 'Rights'.
str, date, datetime, or tuple of same: 'Date'. If a non-str, then it will be formatted as ISO 8601.  Values have been predefined for 'Creator', 'Date', 'Format', and 'Type'. They can be removed by setting them to None. Information is encoded as Dublin Core Metadata.


classmatplotlib.backends.backend_svg.RendererSVG(width, height, svgwriter, basename=None, image_dpi=72, *, metadata=None)[source]

Bases: matplotlib.backend_bases.RendererBase   close_group(s)[source]

Close a grouping element with label s. Only used by the SVG renderer.
   draw_gouraud_triangle(gc, points, colors, trans)[source]

Draw a Gouraud-shaded triangle.  Parameters

gcGraphicsContextBase

The graphics context.
points(3, 2) array-like

Array of (x, y) points for the triangle.
colors(3, 4) array-like

RGBA colors for each point of the triangle.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.
   draw_gouraud_triangles(gc, triangles_array, colors_array, transform)[source]

Draw a series of Gouraud triangles.  Parameters

points(N, 3, 2) array-like

Array of N (x, y) points for the triangles.
colors(N, 3, 4) array-like

Array of N RGBA colors for each point of the triangles.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.
   draw_image(gc, x, y, im, transform=None)[source]

Draw an RGBA image.  Parameters

gcGraphicsContextBase

A graphics context with clipping information.
xscalar

The distance in physical units (i.e., dots or pixels) from the left hand side of the canvas.
yscalar

The distance in physical units (i.e., dots or pixels) from the bottom side of the canvas.
im(N, M, 4) array-like of np.uint8

An array of RGBA pixels.
transformmatplotlib.transforms.Affine2DBase

If and only if the concrete backend is written such that option_scale_image() returns True, an affine transformation (i.e., an Affine2DBase) may be passed to draw_image(). The translation vector of the transformation is given in physical units (i.e., dots or pixels). Note that the transformation does not override x and y, and has to be applied before translating the result by x and y (this can be accomplished by adding x and y to the translation vector defined by transform).
   draw_markers(gc, marker_path, marker_trans, path, trans, rgbFace=None)[source]

Draw a marker at each of path's vertices (excluding control points). This provides a fallback implementation of draw_markers that makes multiple calls to draw_path(). Some backends may want to override this method in order to draw the marker only once and reuse it multiple times.  Parameters

gcGraphicsContextBase

The graphics context.
marker_transmatplotlib.transforms.Transform

An affine transform applied to the marker.
transmatplotlib.transforms.Transform

An affine transform applied to the path.
   draw_path(gc, path, transform, rgbFace=None)[source]

Draw a Path instance using the given affine transform.
   draw_path_collection(gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls, offset_position)[source]

Draw a collection of paths selecting drawing properties from the lists facecolors, edgecolors, linewidths, linestyles and antialiaseds. offsets is a list of offsets to apply to each of the paths. The offsets in offsets are first transformed by offsetTrans before being applied. offset_position is unused now, but the argument is kept for backwards compatibility. This provides a fallback implementation of draw_path_collection() that makes multiple calls to draw_path(). Some backends may want to override this in order to render each set of path data only once, and then reference that path multiple times with the different offsets, colors, styles etc. The generator methods _iter_collection_raw_paths() and _iter_collection() are provided to help with (and standardize) the implementation across backends. It is highly recommended to use those generators, so that changes to the behavior of draw_path_collection() can be made globally.
   draw_tex(gc, x, y, s, prop, angle, *, mtext=None)[source]

   draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[source]

Draw the text instance.  Parameters

gcGraphicsContextBase

The graphics context.
xfloat

The x location of the text in display coords.
yfloat

The y location of the text baseline in display coords.
sstr

The text string.
propmatplotlib.font_manager.FontProperties

The font properties.
anglefloat

The rotation angle in degrees anti-clockwise.
mtextmatplotlib.text.Text

The original text object to be rendered.     Notes Note for backend implementers: When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work properly), it helps to change the line in text.py: if 0: bbox_artist(self, renderer)
 to if 1, and then the actual bounding box will be plotted along with your text.
   finalize()[source]

   flipy()[source]

Return whether y values increase from top to bottom. Note that this only affects drawing of texts and images.
   get_canvas_width_height()[source]

Return the canvas width and height in display coords.
   get_image_magnification()[source]

Get the factor by which to magnify images passed to draw_image(). Allows a backend to have images at a different resolution to other artists.
   get_text_width_height_descent(s, prop, ismath)[source]

Get the width, height, and descent (offset from the bottom to the baseline), in display coords, of the string s with FontProperties prop.
   propertymathtext_parser[source]

   open_group(s, gid=None)[source]

Open a grouping element with label s and gid (if set) as id. Only used by the SVG renderer.
   option_image_nocomposite()[source]

Return whether image composition by Matplotlib should be skipped. Raster backends should usually return False (letting the C-level rasterizer take care of image composition); vector backends should usually return not rcParams["image.composite_image"].
   option_scale_image()[source]

Return whether arbitrary affine transformations in draw_image() are supported (True for most vector backends).


close_group(s)[source]

Close a grouping element with label s. Only used by the SVG renderer.


draw_gouraud_triangle(gc, points, colors, trans)[source]

Draw a Gouraud-shaded triangle.  Parameters

gcGraphicsContextBase

The graphics context.
points(3, 2) array-like

Array of (x, y) points for the triangle.
colors(3, 4) array-like

RGBA colors for each point of the triangle.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.


draw_gouraud_triangles(gc, triangles_array, colors_array, transform)[source]

Draw a series of Gouraud triangles.  Parameters

points(N, 3, 2) array-like

Array of N (x, y) points for the triangles.
colors(N, 3, 4) array-like

Array of N RGBA colors for each point of the triangles.
transformmatplotlib.transforms.Transform

An affine transform to apply to the points.


draw_image(gc, x, y, im, transform=None)[source]

Draw an RGBA image.  Parameters

gcGraphicsContextBase

A graphics context with clipping information.
xscalar

The distance in physical units (i.e., dots or pixels) from the left hand side of the canvas.
yscalar

The distance in physical units (i.e., dots or pixels) from the bottom side of the canvas.
im(N, M, 4) array-like of np.uint8

An array of RGBA pixels.
transformmatplotlib.transforms.Affine2DBase

If and only if the concrete backend is written such that option_scale_image() returns True, an affine transformation (i.e., an Affine2DBase) may be passed to draw_image(). The translation vector of the transformation is given in physical units (i.e., dots or pixels). Note that the transformation does not override x and y, and has to be applied before translating the result by x and y (this can be accomplished by adding x and y to the translation vector defined by transform).


draw_markers(gc, marker_path, marker_trans, path, trans, rgbFace=None)[source]

Draw a marker at each of path's vertices (excluding control points). This provides a fallback implementation of draw_markers that makes multiple calls to draw_path(). Some backends may want to override this method in order to draw the marker only once and reuse it multiple times.  Parameters

gcGraphicsContextBase

The graphics context.
marker_transmatplotlib.transforms.Transform

An affine transform applied to the marker.
transmatplotlib.transforms.Transform

An affine transform applied to the path.


draw_path(gc, path, transform, rgbFace=None)[source]

Draw a Path instance using the given affine transform.


draw_path_collection(gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls, offset_position)[source]

Draw a collection of paths selecting drawing properties from the lists facecolors, edgecolors, linewidths, linestyles and antialiaseds. offsets is a list of offsets to apply to each of the paths. The offsets in offsets are first transformed by offsetTrans before being applied. offset_position is unused now, but the argument is kept for backwards compatibility. This provides a fallback implementation of draw_path_collection() that makes multiple calls to draw_path(). Some backends may want to override this in order to render each set of path data only once, and then reference that path multiple times with the different offsets, colors, styles etc. The generator methods _iter_collection_raw_paths() and _iter_collection() are provided to help with (and standardize) the implementation across backends. It is highly recommended to use those generators, so that changes to the behavior of draw_path_collection() can be made globally.


draw_tex(gc, x, y, s, prop, angle, *, mtext=None)[source]


draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[source]

Draw the text instance.  Parameters

gcGraphicsContextBase

The graphics context.
xfloat

The x location of the text in display coords.
yfloat

The y location of the text baseline in display coords.
sstr

The text string.
propmatplotlib.font_manager.FontProperties

The font properties.
anglefloat

The rotation angle in degrees anti-clockwise.
mtextmatplotlib.text.Text

The original text object to be rendered.     Notes Note for backend implementers: When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work properly), it helps to change the line in text.py: if 0: bbox_artist(self, renderer)
 to if 1, and then the actual bounding box will be plotted along with your text.


flipy()[source]

Return whether y values increase from top to bottom. Note that this only affects drawing of texts and images.


get_canvas_width_height()[source]

Return the canvas width and height in display coords.


get_image_magnification()[source]

Get the factor by which to magnify images passed to draw_image(). Allows a backend to have images at a different resolution to other artists.


get_text_width_height_descent(s, prop, ismath)[source]

Get the width, height, and descent (offset from the bottom to the baseline), in display coords, of the string s with FontProperties prop.


open_group(s, gid=None)[source]

Open a grouping element with label s and gid (if set) as id. Only used by the SVG renderer.


option_image_nocomposite()[source]

Return whether image composition by Matplotlib should be skipped. Raster backends should usually return False (letting the C-level rasterizer take care of image composition); vector backends should usually return not rcParams["image.composite_image"].


option_scale_image()[source]

Return whether arbitrary affine transformations in draw_image() are supported (True for most vector backends).


matplotlib.backends.backend_svg.short_float_fmt(x)[source]

Create a short string representation of a float, which is %f formatting with trailing zeros and the decimal point removed.


classmatplotlib.backends.backend_svg.XMLWriter(file)[source]

Bases: object  Parameters

filewritable text file-like object

     close(id)[source]

Close open elements, up to (and including) the element identified by the given identifier.  Parameters
 id

Element identifier, as returned by the start() method.
   comment(comment)[source]

Add a comment to the output stream.  Parameters

commentstr

Comment text.
   data(text)[source]

Add character data to the output stream.  Parameters

textstr

Character data.
   element(tag, text=None, attrib={}, **extra)[source]

Add an entire element. This is the same as calling start(), data(), and end() in sequence. The text argument can be omitted.
   end(tag=None, indent=True)[source]

Close the current element (opened by the most recent call to start()).  Parameters
 tag

Element tag. If given, the tag must match the start tag. If omitted, the current element is closed.
   flush()[source]

Flush the output stream.
   start(tag, attrib={}, **extra)[source]

Open a new element. Attributes can be given as keyword arguments, or as a string/string dictionary. The method returns an opaque identifier that can be passed to the close() method, to close all open elements up to and including this one.  Parameters
 tag

Element tag.  attrib

Attribute dictionary. Alternatively, attributes can be given as keyword arguments.    Returns
 An element identifier.


close(id)[source]

Close open elements, up to (and including) the element identified by the given identifier.  Parameters
 id

Element identifier, as returned by the start() method.


comment(comment)[source]

Add a comment to the output stream.  Parameters

commentstr

Comment text.


data(text)[source]

Add character data to the output stream.  Parameters

textstr

Character data.


element(tag, text=None, attrib={}, **extra)[source]

Add an entire element. This is the same as calling start(), data(), and end() in sequence. The text argument can be omitted.


end(tag=None, indent=True)[source]

Close the current element (opened by the most recent call to start()).  Parameters
 tag

Element tag. If given, the tag must match the start tag. If omitted, the current element is closed.


flush()[source]

Flush the output stream.


start(tag, attrib={}, **extra)[source]

Open a new element. Attributes can be given as keyword arguments, or as a string/string dictionary. The method returns an opaque identifier that can be passed to the close() method, to close all open elements up to and including this one.  Parameters
 tag

Element tag.  attrib

Attribute dictionary. Alternatively, attributes can be given as keyword arguments.    Returns
 An element identifier.


matplotlib.backends.backend_template.draw_if_interactive()[source]

For image backends - is not required. For GUI backends - this should be overridden if drawing should be done in interactive python mode.


matplotlib.backends.backend_template.FigureCanvas[source]

alias of matplotlib.backends.backend_template.FigureCanvasTemplate


classmatplotlib.backends.backend_template.FigureCanvasTemplate(figure=None)[source]

Bases: matplotlib.backend_bases.FigureCanvasBase The canvas the figure renders into. Calls the draw and print fig methods, creates the renderers, etc. Note: GUI templates will want to connect events for button presses, mouse movements and key presses to functions that call the base class methods button_press_event, button_release_event, motion_notify_event, key_press_event, and key_release_event. See the implementations of the interactive backends for examples.  Attributes

figurematplotlib.figure.Figure

A high-level Figure instance       draw()[source]

Draw the figure using the renderer. It is important that this method actually walk the artist tree even if not output is produced because this will trigger deferred work (like computing limits auto-limits and tick values) that users may want access to before saving to disk.
   filetypes={'eps': 'Encapsulated Postscript', 'foo': 'My magic Foo format', 'jpeg': 'Joint Photographic Experts Group', 'jpg': 'Joint Photographic Experts Group', 'pdf': 'Portable Document Format', 'pgf': 'PGF code for LaTeX', 'png': 'Portable Network Graphics', 'ps': 'Postscript', 'raw': 'Raw RGBA bitmap', 'rgba': 'Raw RGBA bitmap', 'svg': 'Scalable Vector Graphics', 'svgz': 'Scalable Vector Graphics', 'tif': 'Tagged Image File Format', 'tiff': 'Tagged Image File Format'}

   get_default_filetype()[source]

Return the default savefig file format as specified in rcParams["savefig.format"] (default: 'png'). The returned string does not include a period. This method is overridden in backends that only support a single file type.
   print_foo(filename, *args, **kwargs)[source]

Write out format foo. This method is normally called via Figure.savefig and FigureCanvasBase.print_figure, which take care of setting the figure facecolor, edgecolor, and dpi to the desired output values, and will restore them to the original values. Therefore, print_foo does not need to handle these settings.


draw()[source]

Draw the figure using the renderer. It is important that this method actually walk the artist tree even if not output is produced because this will trigger deferred work (like computing limits auto-limits and tick values) that users may want access to before saving to disk.


filetypes={'eps': 'Encapsulated Postscript', 'foo': 'My magic Foo format', 'jpeg': 'Joint Photographic Experts Group', 'jpg': 'Joint Photographic Experts Group', 'pdf': 'Portable Document Format', 'pgf': 'PGF code for LaTeX', 'png': 'Portable Network Graphics', 'ps': 'Postscript', 'raw': 'Raw RGBA bitmap', 'rgba': 'Raw RGBA bitmap', 'svg': 'Scalable Vector Graphics', 'svgz': 'Scalable Vector Graphics', 'tif': 'Tagged Image File Format', 'tiff': 'Tagged Image File Format'}


get_default_filetype()[source]

Return the default savefig file format as specified in rcParams["savefig.format"] (default: 'png'). The returned string does not include a period. This method is overridden in backends that only support a single file type.


print_foo(filename, *args, **kwargs)[source]

Write out format foo. This method is normally called via Figure.savefig and FigureCanvasBase.print_figure, which take care of setting the figure facecolor, edgecolor, and dpi to the desired output values, and will restore them to the original values. Therefore, print_foo does not need to handle these settings.


matplotlib.backends.backend_template.FigureManager[source]

alias of matplotlib.backends.backend_template.FigureManagerTemplate


classmatplotlib.backends.backend_template.FigureManagerTemplate(canvas, num)[source]

Bases: matplotlib.backend_bases.FigureManagerBase Helper class for pyplot mode, wraps everything up into a neat bundle. For non-interactive backends, the base class is sufficient.


classmatplotlib.backends.backend_template.GraphicsContextTemplate[source]

Bases: matplotlib.backend_bases.GraphicsContextBase The graphics context provides the color, line styles, etc... See the cairo and postscript backends for examples of mapping the graphics context attributes (cap styles, join styles, line widths, colors) to a particular backend. In cairo this is done by wrapping a cairo.Context object and forwarding the appropriate calls to it using a dictionary mapping styles to gdk constants. In Postscript, all the work is done by the renderer, mapping line styles to postscript calls. If it's more appropriate to do the mapping at the renderer level (as in the postscript backend), you don't need to override any of the GC methods. If it's more appropriate to wrap an instance (as in the cairo backend) and do the mapping here, you'll need to override several of the setter methods. The base GraphicsContext stores colors as a RGB tuple on the unit interval, e.g., (0.5, 0.0, 1.0). You may need to map this to colors appropriate for your backend.


matplotlib.backends.backend_template.new_figure_manager(num, *args, FigureClass=<class 'matplotlib.figure.Figure'>, **kwargs)[source]

Create a new figure manager instance.


matplotlib.backends.backend_template.new_figure_manager_given_figure(num, figure)[source]

Create a new figure manager instance for the given figure.


classmatplotlib.backends.backend_template.RendererTemplate(dpi)[source]

Bases: matplotlib.backend_bases.RendererBase The renderer handles drawing/rendering operations. This is a minimal do-nothing class that can be used to get started when writing a new backend. Refer to backend_bases.RendererBase for documentation of the methods.   draw_image(gc, x, y, im)[source]

Draw an RGBA image.  Parameters

gcGraphicsContextBase

A graphics context with clipping information.
xscalar

The distance in physical units (i.e., dots or pixels) from the left hand side of the canvas.
yscalar

The distance in physical units (i.e., dots or pixels) from the bottom side of the canvas.
im(N, M, 4) array-like of np.uint8

An array of RGBA pixels.
transformmatplotlib.transforms.Affine2DBase

If and only if the concrete backend is written such that option_scale_image() returns True, an affine transformation (i.e., an Affine2DBase) may be passed to draw_image(). The translation vector of the transformation is given in physical units (i.e., dots or pixels). Note that the transformation does not override x and y, and has to be applied before translating the result by x and y (this can be accomplished by adding x and y to the translation vector defined by transform).
   draw_path(gc, path, transform, rgbFace=None)[source]

Draw a Path instance using the given affine transform.
   draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[source]

Draw the text instance.  Parameters

gcGraphicsContextBase

The graphics context.
xfloat

The x location of the text in display coords.
yfloat

The y location of the text baseline in display coords.
sstr

The text string.
propmatplotlib.font_manager.FontProperties

The font properties.
anglefloat

The rotation angle in degrees anti-clockwise.
mtextmatplotlib.text.Text

The original text object to be rendered.     Notes Note for backend implementers: When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work properly), it helps to change the line in text.py: if 0: bbox_artist(self, renderer)
 to if 1, and then the actual bounding box will be plotted along with your text.
   flipy()[source]

Return whether y values increase from top to bottom. Note that this only affects drawing of texts and images.
   get_canvas_width_height()[source]

Return the canvas width and height in display coords.
   get_text_width_height_descent(s, prop, ismath)[source]

Get the width, height, and descent (offset from the bottom to the baseline), in display coords, of the string s with FontProperties prop.
   new_gc()[source]

Return an instance of a GraphicsContextBase.
   points_to_pixels(points)[source]

Convert points to display units. You need to override this function (unless your backend doesn't have a dpi, e.g., postscript or svg). Some imaging systems assume some value for pixels per inch: points to pixels = points * pixels_per_inch/72 * dpi/72
  Parameters

pointsfloat or array-like

a float or a numpy array of float    Returns
 Points converted to pixels


draw_image(gc, x, y, im)[source]

Draw an RGBA image.  Parameters

gcGraphicsContextBase

A graphics context with clipping information.
xscalar

The distance in physical units (i.e., dots or pixels) from the left hand side of the canvas.
yscalar

The distance in physical units (i.e., dots or pixels) from the bottom side of the canvas.
im(N, M, 4) array-like of np.uint8

An array of RGBA pixels.
transformmatplotlib.transforms.Affine2DBase

If and only if the concrete backend is written such that option_scale_image() returns True, an affine transformation (i.e., an Affine2DBase) may be passed to draw_image(). The translation vector of the transformation is given in physical units (i.e., dots or pixels). Note that the transformation does not override x and y, and has to be applied before translating the result by x and y (this can be accomplished by adding x and y to the translation vector defined by transform).


draw_path(gc, path, transform, rgbFace=None)[source]

Draw a Path instance using the given affine transform.


draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[source]

Draw the text instance.  Parameters

gcGraphicsContextBase

The graphics context.
xfloat

The x location of the text in display coords.
yfloat

The y location of the text baseline in display coords.
sstr

The text string.
propmatplotlib.font_manager.FontProperties

The font properties.
anglefloat

The rotation angle in degrees anti-clockwise.
mtextmatplotlib.text.Text

The original text object to be rendered.     Notes Note for backend implementers: When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work properly), it helps to change the line in text.py: if 0: bbox_artist(self, renderer)
 to if 1, and then the actual bounding box will be plotted along with your text.


flipy()[source]

Return whether y values increase from top to bottom. Note that this only affects drawing of texts and images.


get_canvas_width_height()[source]

Return the canvas width and height in display coords.


get_text_width_height_descent(s, prop, ismath)[source]

Get the width, height, and descent (offset from the bottom to the baseline), in display coords, of the string s with FontProperties prop.


new_gc()[source]

Return an instance of a GraphicsContextBase.


points_to_pixels(points)[source]

Convert points to display units. You need to override this function (unless your backend doesn't have a dpi, e.g., postscript or svg). Some imaging systems assume some value for pixels per inch: points to pixels = points * pixels_per_inch/72 * dpi/72
  Parameters

pointsfloat or array-like

a float or a numpy array of float    Returns
 Points converted to pixels


matplotlib.backends.backend_template.show(*, block=None)[source]

For image backends - is not required. For GUI backends - show() is usually the last line of a pyplot script and tells the backend that it is time to draw. In interactive mode, this should do nothing.


matplotlib.backends.backend_tkagg.FigureCanvas[source]

alias of matplotlib.backends.backend_tkagg.FigureCanvasTkAgg


classmatplotlib.backends.backend_tkagg.FigureCanvasTkAgg(figure=None, master=None, resize_callback=<deprecated parameter>)[source]

Bases: matplotlib.backends.backend_agg.FigureCanvasAgg, matplotlib.backends._backend_tk.FigureCanvasTk   blit(bbox=None)[source]

Blit the canvas in bbox (default entire canvas).
   draw()[source]

Render the Figure. It is important that this method actually walk the artist tree even if not output is produced because this will trigger deferred work (like computing limits auto-limits and tick values) that users may want access to before saving to disk.


blit(bbox=None)[source]

Blit the canvas in bbox (default entire canvas).


draw()[source]

Render the Figure. It is important that this method actually walk the artist tree even if not output is produced because this will trigger deferred work (like computing limits auto-limits and tick values) that users may want access to before saving to disk.


matplotlib.backends.backend_tkcairo.FigureCanvas[source]

alias of matplotlib.backends.backend_tkcairo.FigureCanvasTkCairo


classmatplotlib.backends.backend_tkcairo.FigureCanvasTkCairo(*args, **kwargs)[source]

Bases: matplotlib.backends.backend_cairo.FigureCanvasCairo, matplotlib.backends._backend_tk.FigureCanvasTk   draw()[source]

Render the Figure. It is important that this method actually walk the artist tree even if not output is produced because this will trigger deferred work (like computing limits auto-limits and tick values) that users may want access to before saving to disk.


matplotlib.backends.backend_webagg.FigureCanvas[source]

alias of matplotlib.backends.backend_webagg.FigureCanvasWebAgg


classmatplotlib.backends.backend_webagg.FigureCanvasWebAgg(*args, **kwargs)[source]

Bases: matplotlib.backends.backend_webagg_core.FigureCanvasWebAggCore


classmatplotlib.backends.backend_webagg.ServerThread(group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None)[source]

Bases: threading.Thread This constructor should always be called with keyword arguments. Arguments are: group should be None; reserved for future extension when a ThreadGroup class is implemented. target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called. name is the thread name. By default, a unique name is constructed of the form "Thread-N" where N is a small decimal number. args is the argument tuple for the target invocation. Defaults to (). kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}. If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.   run()[source]

Method representing the thread's activity. You may override this method in a subclass. The standard run() method invokes the callable object passed to the object's constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.


run()[source]

Method representing the thread's activity. You may override this method in a subclass. The standard run() method invokes the callable object passed to the object's constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.


matplotlib.backends.backend_webagg.show()[source]

Show all figures. show blocks by calling mainloop if block is True, or if it is None and we are neither in IPython's %pylab mode, nor in interactive mode.


classmatplotlib.backends.backend_webagg.WebAggApplication(url_prefix='')[source]

Bases: tornado.web.Application   classAllFiguresPage(application, request, *, url_prefix='', **kwargs)[source]

Bases: tornado.web.RequestHandler   get()[source]

   classDownload(application:tornado.web.Application, request:tornado.httputil.HTTPServerRequest, **kwargs:Any)[source]

Bases: tornado.web.RequestHandler   get(fignum, fmt)[source]

   classFavIcon(application:tornado.web.Application, request:tornado.httputil.HTTPServerRequest, **kwargs:Any)[source]

Bases: tornado.web.RequestHandler   get()[source]

   classMplJs(application:tornado.web.Application, request:tornado.httputil.HTTPServerRequest, **kwargs:Any)[source]

Bases: tornado.web.RequestHandler   get()[source]

   classSingleFigurePage(application, request, *, url_prefix='', **kwargs)[source]

Bases: tornado.web.RequestHandler   get(fignum)[source]

   classWebSocket(application:tornado.web.Application, request:tornado.httputil.HTTPServerRequest, **kwargs:Any)[source]

Bases: tornado.websocket.WebSocketHandler   on_close()[source]

Invoked when the WebSocket is closed. If the connection was closed cleanly and a status code or reason phrase was supplied, these values will be available as the attributes self.close_code and self.close_reason.  Changed in version 4.0: Added close_code and close_reason attributes.
   on_message(message)[source]

Handle incoming messages on the WebSocket This method must be overridden.  Changed in version 4.5: on_message can be a coroutine.
   open(fignum)[source]

Invoked when a new WebSocket is opened. The arguments to open are extracted from the tornado.web.URLSpec regular expression, just like the arguments to tornado.web.RequestHandler.get. open may be a coroutine. on_message will not be called until open has returned.  Changed in version 5.1: open may be a coroutine.
   send_binary(blob)[source]

   send_json(content)[source]

   supports_binary=True

   classmethodinitialize(url_prefix='', port=None, address=None)[source]

   initialized=False

   classmethodstart()[source]

   started=False


classAllFiguresPage(application, request, *, url_prefix='', **kwargs)[source]

Bases: tornado.web.RequestHandler   get()[source]


classDownload(application:tornado.web.Application, request:tornado.httputil.HTTPServerRequest, **kwargs:Any)[source]

Bases: tornado.web.RequestHandler   get(fignum, fmt)[source]


classFavIcon(application:tornado.web.Application, request:tornado.httputil.HTTPServerRequest, **kwargs:Any)[source]

Bases: tornado.web.RequestHandler   get()[source]


classMplJs(application:tornado.web.Application, request:tornado.httputil.HTTPServerRequest, **kwargs:Any)[source]

Bases: tornado.web.RequestHandler   get()[source]


classSingleFigurePage(application, request, *, url_prefix='', **kwargs)[source]

Bases: tornado.web.RequestHandler   get(fignum)[source]


classWebSocket(application:tornado.web.Application, request:tornado.httputil.HTTPServerRequest, **kwargs:Any)[source]

Bases: tornado.websocket.WebSocketHandler   on_close()[source]

Invoked when the WebSocket is closed. If the connection was closed cleanly and a status code or reason phrase was supplied, these values will be available as the attributes self.close_code and self.close_reason.  Changed in version 4.0: Added close_code and close_reason attributes.
   on_message(message)[source]

Handle incoming messages on the WebSocket This method must be overridden.  Changed in version 4.5: on_message can be a coroutine.
   open(fignum)[source]

Invoked when a new WebSocket is opened. The arguments to open are extracted from the tornado.web.URLSpec regular expression, just like the arguments to tornado.web.RequestHandler.get. open may be a coroutine. on_message will not be called until open has returned.  Changed in version 5.1: open may be a coroutine.
   send_binary(blob)[source]

   send_json(content)[source]

   supports_binary=True


on_close()[source]

Invoked when the WebSocket is closed. If the connection was closed cleanly and a status code or reason phrase was supplied, these values will be available as the attributes self.close_code and self.close_reason.  Changed in version 4.0: Added close_code and close_reason attributes.


on_message(message)[source]

Handle incoming messages on the WebSocket This method must be overridden.  Changed in version 4.5: on_message can be a coroutine.


open(fignum)[source]

Invoked when a new WebSocket is opened. The arguments to open are extracted from the tornado.web.URLSpec regular expression, just like the arguments to tornado.web.RequestHandler.get. open may be a coroutine. on_message will not be called until open has returned.  Changed in version 5.1: open may be a coroutine.


matplotlib.bezier A module providing some utility functions regarding Bezier path manipulation.   classmatplotlib.bezier.BezierSegment(control_points)[source]

Bases: object A d-dimensional Bezier segment.  Parameters

control_points(N, d) array

Location of the N control points.       axis_aligned_extrema()[source]

Return the dimension and location of the curve's interior extrema. The extrema are the points along the curve where one of its partial derivatives is zero.  Returns

dimsarray of int

Index \(i\) of the partial derivative which is zero at each interior extrema.
dzerosarray of float

Of same size as dims. The \(t\) such that \(d/dx_i B(t) = 0\)
   propertycontrol_points

The control points of the curve.
   propertydegree

Degree of the polynomial. One less the number of control points.
   propertydimension

The dimension of the curve.
   point_at_t(t)[source]

Evaluate the curve at a single point, returning a tuple of d floats.
   propertypolynomial_coefficients

The polynomial coefficients of the Bezier curve.  Warning Follows opposite convention from numpy.polyval.   Returns
 (n+1, d) array

Coefficients after expanding in polynomial basis, where \(n\) is the degree of the bezier curve and \(d\) its dimension. These are the numbers (\(C_j\)) such that the curve can be written \(\sum_{j=0}^n C_j t^j\).     Notes The coefficients are calculated as  \[{n \choose j} \sum_{i=0}^j (-1)^{i+j} {j \choose i} P_i\] where \(P_i\) are the control points of the curve.

   exceptionmatplotlib.bezier.NonIntersectingPathException[source]

Bases: ValueError
   matplotlib.bezier.check_if_parallel(dx1, dy1, dx2, dy2, tolerance=1e-05)[source]

Check if two lines are parallel.  Parameters

dx1, dy1, dx2, dy2float

The gradients dy/dx of the two lines.
tolerancefloat

The angular tolerance in radians up to which the lines are considered parallel.    Returns
 is_parallel

 1 if two lines are parallel in same direction. -1 if two lines are parallel in opposite direction. False otherwise.
   matplotlib.bezier.find_bezier_t_intersecting_with_closedpath(bezier_point_at_t, inside_closedpath, t0=0.0, t1=1.0, tolerance=0.01)[source]

Find the intersection of the Bezier curve with a closed path. The intersection point t is approximated by two parameters t0, t1 such that t0 <= t <= t1. Search starts from t0 and t1 and uses a simple bisecting algorithm therefore one of the end points must be inside the path while the other doesn't. The search stops when the distance of the points parametrized by t0 and t1 gets smaller than the given tolerance.  Parameters

bezier_point_at_tcallable

A function returning x, y coordinates of the Bezier at parameter t. It must have the signature: bezier_point_at_t(t: float) -> tuple[float, float]

inside_closedpathcallable

A function returning True if a given point (x, y) is inside the closed path. It must have the signature: inside_closedpath(point: tuple[float, float]) -> bool

t0, t1float

Start parameters for the search.
tolerancefloat

Maximal allowed distance between the final points.    Returns

t0, t1float

The Bezier path parameters.
   matplotlib.bezier.find_control_points(c1x, c1y, mmx, mmy, c2x, c2y)[source]

Find control points of the Bezier curve passing through (c1x, c1y), (mmx, mmy), and (c2x, c2y), at parametric values 0, 0.5, and 1.
   matplotlib.bezier.get_cos_sin(x0, y0, x1, y1)[source]

   matplotlib.bezier.get_intersection(cx1, cy1, cos_t1, sin_t1, cx2, cy2, cos_t2, sin_t2)[source]

Return the intersection between the line through (cx1, cy1) at angle t1 and the line through (cx2, cy2) at angle t2.
   matplotlib.bezier.get_normal_points(cx, cy, cos_t, sin_t, length)[source]

For a line passing through (cx, cy) and having an angle t, return locations of the two points located along its perpendicular line at the distance of length.
   matplotlib.bezier.get_parallels(bezier2, width)[source]

Given the quadratic Bezier control points bezier2, returns control points of quadratic Bezier lines roughly parallel to given one separated by width.
   matplotlib.bezier.inside_circle(cx, cy, r)[source]

Return a function that checks whether a point is in a circle with center (cx, cy) and radius r. The returned function has the signature: f(xy: tuple[float, float]) -> bool

   matplotlib.bezier.make_wedged_bezier2(bezier2, width, w1=1.0, wm=0.5, w2=0.0)[source]

Being similar to get_parallels, returns control points of two quadratic Bezier lines having a width roughly parallel to given one separated by width.
   matplotlib.bezier.split_bezier_intersecting_with_closedpath(bezier, inside_closedpath, tolerance=0.01)[source]

Split a Bezier curve into two at the intersection with a closed path.  Parameters

bezier(N, 2) array-like

Control points of the Bezier segment. See BezierSegment.
inside_closedpathcallable

A function returning True if a given point (x, y) is inside the closed path. See also find_bezier_t_intersecting_with_closedpath.
tolerancefloat

The tolerance for the intersection. See also find_bezier_t_intersecting_with_closedpath.    Returns
 left, right

Lists of control points for the two Bezier segments.
   matplotlib.bezier.split_de_casteljau(beta, t)[source]

Split a Bezier segment defined by its control points beta into two separate segments divided at t and return their control points.
   matplotlib.bezier.split_path_inout(path, inside, tolerance=0.01, reorder_inout=False)[source]

Divide a path into two segments at the point where inside(x, y) becomes False.


classmatplotlib.bezier.BezierSegment(control_points)[source]

Bases: object A d-dimensional Bezier segment.  Parameters

control_points(N, d) array

Location of the N control points.       axis_aligned_extrema()[source]

Return the dimension and location of the curve's interior extrema. The extrema are the points along the curve where one of its partial derivatives is zero.  Returns

dimsarray of int

Index \(i\) of the partial derivative which is zero at each interior extrema.
dzerosarray of float

Of same size as dims. The \(t\) such that \(d/dx_i B(t) = 0\)
   propertycontrol_points

The control points of the curve.
   propertydegree

Degree of the polynomial. One less the number of control points.
   propertydimension

The dimension of the curve.
   point_at_t(t)[source]

Evaluate the curve at a single point, returning a tuple of d floats.
   propertypolynomial_coefficients

The polynomial coefficients of the Bezier curve.  Warning Follows opposite convention from numpy.polyval.   Returns
 (n+1, d) array

Coefficients after expanding in polynomial basis, where \(n\) is the degree of the bezier curve and \(d\) its dimension. These are the numbers (\(C_j\)) such that the curve can be written \(\sum_{j=0}^n C_j t^j\).     Notes The coefficients are calculated as  \[{n \choose j} \sum_{i=0}^j (-1)^{i+j} {j \choose i} P_i\] where \(P_i\) are the control points of the curve.


axis_aligned_extrema()[source]

Return the dimension and location of the curve's interior extrema. The extrema are the points along the curve where one of its partial derivatives is zero.  Returns

dimsarray of int

Index \(i\) of the partial derivative which is zero at each interior extrema.
dzerosarray of float

Of same size as dims. The \(t\) such that \(d/dx_i B(t) = 0\)


point_at_t(t)[source]

Evaluate the curve at a single point, returning a tuple of d floats.


matplotlib.bezier.check_if_parallel(dx1, dy1, dx2, dy2, tolerance=1e-05)[source]

Check if two lines are parallel.  Parameters

dx1, dy1, dx2, dy2float

The gradients dy/dx of the two lines.
tolerancefloat

The angular tolerance in radians up to which the lines are considered parallel.    Returns
 is_parallel

 1 if two lines are parallel in same direction. -1 if two lines are parallel in opposite direction. False otherwise.


matplotlib.bezier.find_bezier_t_intersecting_with_closedpath(bezier_point_at_t, inside_closedpath, t0=0.0, t1=1.0, tolerance=0.01)[source]

Find the intersection of the Bezier curve with a closed path. The intersection point t is approximated by two parameters t0, t1 such that t0 <= t <= t1. Search starts from t0 and t1 and uses a simple bisecting algorithm therefore one of the end points must be inside the path while the other doesn't. The search stops when the distance of the points parametrized by t0 and t1 gets smaller than the given tolerance.  Parameters

bezier_point_at_tcallable

A function returning x, y coordinates of the Bezier at parameter t. It must have the signature: bezier_point_at_t(t: float) -> tuple[float, float]

inside_closedpathcallable

A function returning True if a given point (x, y) is inside the closed path. It must have the signature: inside_closedpath(point: tuple[float, float]) -> bool

t0, t1float

Start parameters for the search.
tolerancefloat

Maximal allowed distance between the final points.    Returns

t0, t1float

The Bezier path parameters.


matplotlib.bezier.find_control_points(c1x, c1y, mmx, mmy, c2x, c2y)[source]

Find control points of the Bezier curve passing through (c1x, c1y), (mmx, mmy), and (c2x, c2y), at parametric values 0, 0.5, and 1.


matplotlib.bezier.get_cos_sin(x0, y0, x1, y1)[source]


matplotlib.bezier.get_intersection(cx1, cy1, cos_t1, sin_t1, cx2, cy2, cos_t2, sin_t2)[source]

Return the intersection between the line through (cx1, cy1) at angle t1 and the line through (cx2, cy2) at angle t2.


matplotlib.bezier.get_normal_points(cx, cy, cos_t, sin_t, length)[source]

For a line passing through (cx, cy) and having an angle t, return locations of the two points located along its perpendicular line at the distance of length.


matplotlib.bezier.get_parallels(bezier2, width)[source]

Given the quadratic Bezier control points bezier2, returns control points of quadratic Bezier lines roughly parallel to given one separated by width.


matplotlib.bezier.inside_circle(cx, cy, r)[source]

Return a function that checks whether a point is in a circle with center (cx, cy) and radius r. The returned function has the signature: f(xy: tuple[float, float]) -> bool


matplotlib.bezier.make_wedged_bezier2(bezier2, width, w1=1.0, wm=0.5, w2=0.0)[source]

Being similar to get_parallels, returns control points of two quadratic Bezier lines having a width roughly parallel to given one separated by width.


exceptionmatplotlib.bezier.NonIntersectingPathException[source]

Bases: ValueError


matplotlib.bezier.split_bezier_intersecting_with_closedpath(bezier, inside_closedpath, tolerance=0.01)[source]

Split a Bezier curve into two at the intersection with a closed path.  Parameters

bezier(N, 2) array-like

Control points of the Bezier segment. See BezierSegment.
inside_closedpathcallable

A function returning True if a given point (x, y) is inside the closed path. See also find_bezier_t_intersecting_with_closedpath.
tolerancefloat

The tolerance for the intersection. See also find_bezier_t_intersecting_with_closedpath.    Returns
 left, right

Lists of control points for the two Bezier segments.


matplotlib.bezier.split_de_casteljau(beta, t)[source]

Split a Bezier segment defined by its control points beta into two separate segments divided at t and return their control points.


matplotlib.bezier.split_path_inout(path, inside, tolerance=0.01, reorder_inout=False)[source]

Divide a path into two segments at the point where inside(x, y) becomes False.


matplotlib.blocking_input Classes used for blocking interaction with figure windows:  BlockingInput

Creates a callable object to retrieve events in a blocking way for interactive sessions. Base class of the other classes listed here.  BlockingKeyMouseInput

Creates a callable object to retrieve key or mouse clicks in a blocking way for interactive sessions. Used by waitforbuttonpress.  BlockingMouseInput

Creates a callable object to retrieve mouse clicks in a blocking way for interactive sessions. Used by ginput.  BlockingContourLabeler

Creates a callable object to retrieve mouse clicks in a blocking way that will then be used to place labels on a ContourSet. Used by clabel.     classmatplotlib.blocking_input.BlockingContourLabeler(cs)[source]

Bases: matplotlib.blocking_input.BlockingMouseInput Callable for retrieving mouse clicks and key presses in a blocking way. Used to place contour labels.   add_click(event)[source]

Add the coordinates of an event to the list of clicks.  Parameters

eventMouseEvent

   button1(event)[source]

Process an button-1 event (add a label to a contour).  Parameters

eventMouseEvent

   button3(event)[source]

Process an button-3 event (remove a label if not in inline mode). Unfortunately, if one is doing inline labels, then there is currently no way to fix the broken contour - once humpty-dumpty is broken, he can't be put back together. In inline mode, this does nothing.  Parameters

eventMouseEvent

   pop_click(event, index=- 1)[source]

Remove a click (by default, the last) from the list of clicks.  Parameters

eventMouseEvent

   classmatplotlib.blocking_input.BlockingInput(fig, eventslist=())[source]

Bases: object Callable for retrieving events in a blocking way.   add_event(event)[source]

For base class, this just appends an event to events.
   cleanup()[source]

Disconnect all callbacks.
   on_event(event)[source]

Event handler; will be passed to the current figure to retrieve events.
   pop(index=- 1)[source]

Remove an event from the event list -- by default, the last. Note that this does not check that there are events, much like the normal pop method. If no events exist, this will throw an exception.
   pop_event(index=- 1)[source]

Remove an event from the event list -- by default, the last. Note that this does not check that there are events, much like the normal pop method. If no events exist, this will throw an exception.
   post_event()[source]

For baseclass, do nothing but collect events.

   classmatplotlib.blocking_input.BlockingKeyMouseInput(fig)[source]

Bases: matplotlib.blocking_input.BlockingInput Callable for retrieving mouse clicks and key presses in a blocking way.   post_event()[source]

Determine if it is a key event.

   classmatplotlib.blocking_input.BlockingMouseInput(fig, mouse_add=MouseButton.LEFT, mouse_pop=MouseButton.RIGHT, mouse_stop=MouseButton.MIDDLE)[source]

Bases: matplotlib.blocking_input.BlockingInput Callable for retrieving mouse clicks in a blocking way. This class will also retrieve keypresses and map them to mouse clicks: delete and backspace are a right click, enter is like a middle click, and all others are like a left click.   add_click(event)[source]

Add the coordinates of an event to the list of clicks.  Parameters

eventMouseEvent

   button_add=1[source]

   button_pop=3[source]

   button_stop=2[source]

   cleanup(event=None)[source]

 Parameters

eventMouseEvent, optional

Not used
   key_event()[source]

Process a key press event, mapping keys to appropriate mouse clicks.
   mouse_event()[source]

Process a mouse click event.
   mouse_event_add(event)[source]

Process an button-1 event (add a click if inside axes).  Parameters

eventMouseEvent

   mouse_event_pop(event)[source]

Process an button-3 event (remove the last click).  Parameters

eventMouseEvent

   mouse_event_stop(event)[source]

Process an button-2 event (end blocking input).  Parameters

eventMouseEvent

   pop(event, index=- 1)[source]

Remove a click and the associated event from the list of clicks. Defaults to the last click.
   pop_click(event, index=- 1)[source]

Remove a click (by default, the last) from the list of clicks.  Parameters

eventMouseEvent

   post_event()[source]

Process an event.


classmatplotlib.blocking_input.BlockingContourLabeler(cs)[source]

Bases: matplotlib.blocking_input.BlockingMouseInput Callable for retrieving mouse clicks and key presses in a blocking way. Used to place contour labels.   add_click(event)[source]

Add the coordinates of an event to the list of clicks.  Parameters

eventMouseEvent

   button1(event)[source]

Process an button-1 event (add a label to a contour).  Parameters

eventMouseEvent

   button3(event)[source]

Process an button-3 event (remove a label if not in inline mode). Unfortunately, if one is doing inline labels, then there is currently no way to fix the broken contour - once humpty-dumpty is broken, he can't be put back together. In inline mode, this does nothing.  Parameters

eventMouseEvent

   pop_click(event, index=- 1)[source]

Remove a click (by default, the last) from the list of clicks.  Parameters

eventMouseEvent


add_click(event)[source]

Add the coordinates of an event to the list of clicks.  Parameters

eventMouseEvent


button1(event)[source]

Process an button-1 event (add a label to a contour).  Parameters

eventMouseEvent


button3(event)[source]

Process an button-3 event (remove a label if not in inline mode). Unfortunately, if one is doing inline labels, then there is currently no way to fix the broken contour - once humpty-dumpty is broken, he can't be put back together. In inline mode, this does nothing.  Parameters

eventMouseEvent


pop_click(event, index=- 1)[source]

Remove a click (by default, the last) from the list of clicks.  Parameters

eventMouseEvent


classmatplotlib.blocking_input.BlockingInput(fig, eventslist=())[source]

Bases: object Callable for retrieving events in a blocking way.   add_event(event)[source]

For base class, this just appends an event to events.
   cleanup()[source]

Disconnect all callbacks.
   on_event(event)[source]

Event handler; will be passed to the current figure to retrieve events.
   pop(index=- 1)[source]

Remove an event from the event list -- by default, the last. Note that this does not check that there are events, much like the normal pop method. If no events exist, this will throw an exception.
   pop_event(index=- 1)[source]

Remove an event from the event list -- by default, the last. Note that this does not check that there are events, much like the normal pop method. If no events exist, this will throw an exception.
   post_event()[source]

For baseclass, do nothing but collect events.


add_event(event)[source]

For base class, this just appends an event to events.


cleanup()[source]

Disconnect all callbacks.


on_event(event)[source]

Event handler; will be passed to the current figure to retrieve events.


pop(index=- 1)[source]

Remove an event from the event list -- by default, the last. Note that this does not check that there are events, much like the normal pop method. If no events exist, this will throw an exception.


pop_event(index=- 1)[source]

Remove an event from the event list -- by default, the last. Note that this does not check that there are events, much like the normal pop method. If no events exist, this will throw an exception.