class matplotlib.textpath.TextPath(xy, s, size=None, prop=None, _interpolation_steps=1, usetex=False, *args, **kwargs)
[source]
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.
Parameters: |
|
---|
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 Demo Text Path.
codes
Return the codes
get_size(self)
[source]
Get the text size.
is_math_text(self, s)
[source]
[Deprecated] Returns True if the given string s contains any mathtext.
Deprecated since version 3.1.
set_size(self, size)
[source]
Set the text size.
text_get_vertices_codes(self, prop, s, usetex)
[source]
[Deprecated] Convert string s to a (vertices, codes) pair using font property prop.
Deprecated since version 3.1.
vertices
Return the cached path after updating it if necessary.
class matplotlib.textpath.TextToPath
[source]
Bases: object
A class that converts strings to paths.
DPI = 72
FONT_SCALE = 100.0
get_glyphs_mathtext(self, prop, s, glyph_map=None, return_new_glyphs_only=False)
[source]
Parse mathtext string s and convert it to a (vertices, codes) pair.
get_glyphs_tex(self, prop, s, glyph_map=None, return_new_glyphs_only=False)
[source]
Convert the string s to vertices and codes using usetex mode.
get_glyphs_with_font(self, font, s, glyph_map=None, return_new_glyphs_only=False)
[source]
Convert string s to vertices and codes using the provided ttf font.
get_texmanager(self)
[source]
Return the cached TexManager
instance.
get_text_path(self, prop, s, ismath=False, usetex=<deprecated parameter>)
[source]
Convert text s to path (a tuple of vertices and codes for matplotlib.path.Path).
Parameters: |
|
---|---|
Returns: |
|
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.
get_text_width_height_descent(self, s, prop, ismath)
[source]
glyph_to_path(self, font, currx=0.0)
[source]
[Deprecated] Convert the font's current glyph to a (vertices, codes) pair.
Deprecated since version 3.1.
tex_font_map
[Deprecated]
Deprecated since version 3.0:
© 2012–2018 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.1.1/api/textpath_api.html