MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / TextPath

Class TextPath

lib/matplotlib/textpath.py:272–376  ·  view source on GitHub ↗

Create a path from the text.

Source from the content-addressed store, hash-verified

270
271
272class TextPath(Path):
273 """
274 Create a path from the text.
275 """
276
277 def __init__(self, xy, s, size=None, prop=None,
278 _interpolation_steps=1, usetex=False):
279 r"""
280 Create a path from the text. Note that it simply is a path,
281 not an artist. You need to use the `.PathPatch` (or other artists)
282 to draw this path onto the canvas.
283
284 Parameters
285 ----------
286 xy : tuple or array of two float values
287 Position of the text. For no offset, use ``xy=(0, 0)``.
288
289 s : str
290 The text to convert to a path.
291
292 size : float, optional
293 Font size in points. Defaults to the size specified via the font
294 properties *prop*.
295
296 prop : `~matplotlib.font_manager.FontProperties`, optional
297 Font property. If not provided, will use a default
298 `.FontProperties` with parameters from the
299 :ref:`rcParams<customizing-with-dynamic-rc-settings>`.
300
301 _interpolation_steps : int, optional
302 (Currently ignored)
303
304 usetex : bool, default: False
305 Whether to use tex rendering.
306
307 Examples
308 --------
309 The following creates a path from the string "ABC" with Helvetica
310 font face; and another path from the latex fraction 1/2::
311
312 from matplotlib.text import TextPath
313 from matplotlib.font_manager import FontProperties
314
315 fp = FontProperties(family="Helvetica", style="italic")
316 path1 = TextPath((12, 12), "ABC", size=12, prop=fp)
317 path2 = TextPath((0, 0), r"$\frac{1}{2}$", size=12, usetex=True)
318
319 Also see :doc:`/gallery/text_labels_and_annotations/demo_text_path`.
320 """
321 # Circular import.
322 from matplotlib.text import Text
323
324 prop = FontProperties._from_any(prop)
325 if size is None:
326 size = prop.get_size_in_points()
327
328 self._xy = xy
329 self.set_size(size)

Callers 8

__init__Method · 0.90
_set_mathtext_pathMethod · 0.90
plot_pathsFunction · 0.90
test_copyFunction · 0.90
text3dFunction · 0.90
demo_text_path.pyFile · 0.90
create_text_axesFunction · 0.90

Calls

no outgoing calls

Tested by 2

plot_pathsFunction · 0.72
test_copyFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…