Bases: matplotlib.path.Path
Create a path from the text.
Create a path from the text. Note that it simply is a path, not an artist. You need to use the PathPatch
(or other artists) to draw this path onto the canvas.
Position of the text. For no offset, use xy=(0, 0)
.
The text to convert to a path.
Font size in points. Defaults to the size specified via the font properties prop.
matplotlib.font_manager.FontProperties
, optional
Font property. If not provided, will use a default FontProperties
with parameters from the rcParams.
(Currently ignored)
Whether to use tex rendering.
The following creates a path from the string "ABC" with Helvetica font face; and another path from the latex fraction 1/2:
from matplotlib.textpath import TextPath from matplotlib.font_manager import FontProperties fp = FontProperties(family="Helvetica", style="italic") path1 = TextPath((12, 12), "ABC", size=12, prop=fp) path2 = TextPath((0, 0), r"$\frac{1}{2}$", size=12, usetex=True)
Also see Using a text as a Path.
Return the codes
Get the text size.
Set the text size.
Return the cached path after updating it if necessary.
Bases: object
A class that converts strings to paths.
Parse mathtext string s and convert it to a (vertices, codes) pair.
Convert the string s to vertices and codes using usetex mode.
Convert string s to vertices and codes using the provided ttf font.
Return the cached TexManager
instance.
Convert text s to path (a tuple of vertices and codes for matplotlib.path.Path).
FontProperties
The font properties for the text.
The text to be converted.
If True, use mathtext parser. If "TeX", use tex for rendering.
A list of numpy arrays containing the x and y coordinates of the vertices.
A list of path codes.
Create a list of vertices and codes from a text, and create a Path
from those:
from matplotlib.path import Path from matplotlib.textpath import TextToPath from matplotlib.font_manager import FontProperties fp = FontProperties(family="Humor Sans", style="italic") verts, codes = TextToPath().get_text_path(fp, "ABC") path = Path(verts, codes, closed=False)
Also see TextPath
for a more direct way to create a path from a text.
© 2012–2021 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.5.1/api/textpath_api.html