@@ -106,22 +106,47 @@ def get_text_width_height_descent(self, s, prop, ismath):
106106
107107 def get_text_path (self , prop , s , ismath = False , usetex = False ):
108108 """
109- convert text *s* to path (a tuple of vertices and codes for
109+ Convert text *s* to path (a tuple of vertices and codes for
110110 matplotlib.path.Path).
111111
112- *prop*
113- font property
112+ Parameters
113+ ----------
114114
115- *s*
116- text to be converted
115+ prop : `matplotlib.font_manager.FontProperties` instance
116+ The font properties for the text.
117117
118- *usetex*
119- If True, use matplotlib usetex mode .
118+ s : str
119+ The text to be converted .
120120
121- *ismath*
122- If True, use mathtext parser. Effective only if usetex == False.
121+ usetex : bool, optional
122+ Whether to use tex rendering. Defaults to `` False`` .
123123
124+ ismath : bool, optional
125+ If True, use mathtext parser. Effective only if
126+ ``usetex == False``.
124127
128+ Returns
129+ -------
130+
131+ verts, codes : tuple of lists
132+ *verts* is a list of numpy arrays containing the x and y
133+ coordinates of the vertices. *codes* is a list of path codes.
134+
135+ Examples
136+ --------
137+
138+ Create a list of vertices and codes from a text, and create a `Path`
139+ from those::
140+
141+ from matplotlib.path import Path
142+ from matplotlib.textpath import TextToPath
143+ from matplotlib.font_manager import FontProperties
144+
145+ fp = FontProperties(family="Humor Sans", style="italic")
146+ verts, codes = TextToPath().get_text_path(fp, "ABC")
147+ path = Path(verts, codes, closed=False)
148+
149+ Also see `TextPath` for a more direct way to create a path from a text.
125150 """
126151 if not usetex :
127152 if not ismath :
@@ -393,16 +418,49 @@ class TextPath(Path):
393418 def __init__ (self , xy , s , size = None , prop = None ,
394419 _interpolation_steps = 1 , usetex = False ,
395420 * kl , ** kwargs ):
396- """
397- Create a path from the text. No support for TeX yet. Note that
398- it simply is a path, not an artist. You need to use the
399- PathPatch (or other artists) to draw this path onto the
400- canvas.
421+ r"""
422+ Create a path from the text. Note that it simply is a path,
423+ not an artist. You need to use the `~.PathPatch` (or other artists)
424+ to draw this path onto the canvas.
425+
426+ Parameters
427+ ----------
428+
429+ xy : tuple or array of two float values
430+ Position of the text. For no offset, use ``xy=(0, 0)``.
431+
432+ s : str
433+ The text to convert to a path.
434+
435+ size : float, optional
436+ Font size in points. Defaults to the size specified via the font
437+ properties *prop*.
438+
439+ prop : `matplotlib.font_manager.FontProperties`, optional
440+ Font property. If not provided, will use a default
441+ ``FontProperties`` with parameters from the
442+ :ref:`rcParams <matplotlib-rcparams>`.
443+
444+ _interpolation_steps : integer, optional
445+ (Currently ignored)
446+
447+ usetex : bool, optional
448+ Whether to use tex rendering. Defaults to ``False``.
449+
450+ Examples
451+ --------
452+
453+ The following creates a path from the string "ABC" with Helvetica
454+ font face; and another path from the latex fraction 1/2::
455+
456+ from matplotlib.textpath import TextPath
457+ from matplotlib.font_manager import FontProperties
458+
459+ fp = FontProperties(family="Helvetica", style="italic")
460+ path1 = TextPath((12,12), "ABC", size=12, prop=fp)
461+ path2 = TextPath((0,0), r"$\frac{1}{2}$", size=12, usetex=True)
401462
402- xy : position of the text.
403- s : text
404- size : font size
405- prop : font property
463+ Also see :doc:`/gallery/text_labels_and_annotations/demo_text_path`.
406464 """
407465
408466 if prop is None :
0 commit comments