matplotlib 3.5.1

Parameters
__init__(self, xy, s, size=None, prop=None, _interpolation_steps=1, usetex=False)

Parameters

xy : tuple or array of two float values

Position of the text. For no offset, use xy=(0, 0) .

s : str

The text to convert to a path.

size : float, optional

Font size in points. Defaults to the size specified via the font properties prop.

prop : `matplotlib.font_manager.FontProperties`, optional

Font property. If not provided, will use a default FontProperties with parameters from the rcParams<customizing-with-dynamic-rc-settings> .

_interpolation_steps : int, optional

(Currently ignored)

usetex : bool, default: False

Whether to use tex rendering.

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.

Examples

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 /gallery/text_labels_and_annotations/demo_text_path .

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /matplotlib/textpath.py#332
type: <class 'function'>
Commit: