A module for parsing a subset of the TeX math syntax and rendering it to a Matplotlib backend.
For a tutorial of its usage, see Writing mathematical expressions. This document is primarily concerned with implementation details.
The module uses pyparsing to parse the TeX expression.
The Bakoma distribution of the TeX Computer Modern fonts, and STIX fonts are supported. There is experimental support for using arbitrary fonts, but results may vary without proper tweaking and metrics for those fonts.
Bases: object
Create a MathTextParser for the given backend output.
[Deprecated] Get the depth of a mathtext string.
A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
The dots-per-inch setting used to render the text.
Offset of the baseline from the bottom of the image, in pixels.
Deprecated since version 3.4.
Parse the given math expression s at the given dpi. If prop is provided, it is a FontProperties
object specifying the "default" font to use in the math expression, used for all non-math text.
The results are cached, so multiple calls to parse
with the same expression should be fast.
[Deprecated] Convert a mathtext string to a grayscale array and depth.
A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
The dots-per-inch setting used to render the text.
The font size in points
Mask array of rasterized tex.
Offset of the baseline from the bottom of the image, in pixels.
Deprecated since version 3.4.
[Deprecated] Render a tex expression to a PNG file.
A writable filename or fileobject.
A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
The text color.
The dots-per-inch setting used to render the text.
The font size in points.
Offset of the baseline from the bottom of the image, in pixels.
Deprecated since version 3.4.
[Deprecated] Convert a mathtext string to an RGBA array and depth.
A valid mathtext string, e.g., r'IQ: $sigma_i=15$'.
The text color.
The dots-per-inch setting used to render the text.
The font size in points.
RGBA color values of rasterized tex, colorized with color.
Offset of the baseline from the bottom of the image, in pixels.
Deprecated since version 3.4.
Bases: object
The base class for the mathtext backend-specific code. MathtextBackend
subclasses interface between mathtext and specific Matplotlib graphics backends.
Subclasses need to override the following:
And optionally, if you need to use a FreeType hinting style:
Get the FreeType hinting type to use with this particular backend.
Return a backend-specific tuple to return to the backend after all processing is done.
Draw a glyph described by info to the reference point (ox, oy).
Draw a filled black rectangle from (x1, y1) to (x2, y2).
Set the dimension of the drawing canvas.
Bases: matplotlib.mathtext.MathtextBackend
Render glyphs and rectangles to an FTImage buffer, which is later transferred to the Agg image by the Agg backend.
Get the FreeType hinting type to use with this particular backend.
Return a backend-specific tuple to return to the backend after all processing is done.
Draw a glyph described by info to the reference point (ox, oy).
Draw a filled black rectangle from (x1, y1) to (x2, y2).
Set the dimension of the drawing canvas.
Bases: matplotlib.mathtext.MathtextBackendAgg
[Deprecated]
Deprecated since version 3.4:
Return a backend-specific tuple to return to the backend after all processing is done.
Bases: matplotlib.mathtext.MathtextBackend
[Deprecated] Store information to write a mathtext rendering to the Cairo backend.
Deprecated since version 3.4.
Return a backend-specific tuple to return to the backend after all processing is done.
Draw a glyph described by info to the reference point (ox, oy).
Draw a filled black rectangle from (x1, y1) to (x2, y2).
Bases: matplotlib.mathtext.MathtextBackend
Store information to write a mathtext rendering to the text path machinery.
Return a backend-specific tuple to return to the backend after all processing is done.
Draw a glyph described by info to the reference point (ox, oy).
Draw a filled black rectangle from (x1, y1) to (x2, y2).
Bases: matplotlib.mathtext.MathtextBackend
[Deprecated] Store information to write a mathtext rendering to the PDF backend.
Deprecated since version 3.4.
Return a backend-specific tuple to return to the backend after all processing is done.
Draw a glyph described by info to the reference point (ox, oy).
Draw a filled black rectangle from (x1, y1) to (x2, y2).
Bases: matplotlib.mathtext.MathtextBackend
[Deprecated] Store information to write a mathtext rendering to the PostScript backend.
Deprecated since version 3.4.
Return a backend-specific tuple to return to the backend after all processing is done.
Draw a glyph described by info to the reference point (ox, oy).
Draw a filled black rectangle from (x1, y1) to (x2, y2).
Bases: matplotlib.mathtext.MathtextBackend
[Deprecated] Store information to write a mathtext rendering to the SVG backend.
Deprecated since version 3.4.
Return a backend-specific tuple to return to the backend after all processing is done.
Draw a glyph described by info to the reference point (ox, oy).
Draw a filled black rectangle from (x1, y1) to (x2, y2).
Return the integer index (from the Unicode table) of symbol.
A single unicode character, a TeX command (e.g. r'pi') or a Type1 symbol name (e.g. 'phi').
If False, always treat as a single unicode character.
Given a math expression, renders it in a closely-clipped bounding box to an image file.
A math expression. The math portion must be enclosed in dollar signs.
Where to write the image data.
FontProperties
, optional
The size and style of the text.
The output dpi. If not set, the dpi is determined as for Figure.savefig
.
The output format, e.g., 'svg', 'pdf', 'ps' or 'png'. If not set, the format is determined as for Figure.savefig
.
[Deprecated]
Deprecated since version 3.4:
© 2012–2021 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.5.1/api/mathtext_api.html