Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0425a7f

Browse files
authored
Merge pull request #23576 from oscargus/softdeprecatetextpath
Soft deprecate the textpath module (import from text instead)
2 parents f232006 + 9b8a598 commit 0425a7f

File tree

12 files changed

+51
-49
lines changed

12 files changed

+51
-49
lines changed

doc/api/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ Alphabetical list of modules:
147147
testing_api.rst
148148
text_api.rst
149149
texmanager_api.rst
150-
textpath_api.rst
151150
ticker_api.rst
152151
tight_bbox_api.rst
153152
tight_layout_api.rst

doc/api/text_api.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
``matplotlib.text``
33
*******************
44

5+
.. redirect-from:: /api/textpath_api
6+
57
.. automodule:: matplotlib.text
68
:no-members:
79

@@ -19,3 +21,13 @@
1921
:members:
2022
:undoc-members:
2123
:show-inheritance:
24+
25+
.. autoclass:: matplotlib.text.TextPath
26+
:members:
27+
:undoc-members:
28+
:show-inheritance:
29+
30+
.. autoclass:: matplotlib.text.TextToPath
31+
:members:
32+
:undoc-members:
33+
:show-inheritance:

doc/api/textpath_api.rst

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/lines_bars_and_markers/multivariate_marker_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import matplotlib.pyplot as plt
1414
from matplotlib.markers import MarkerStyle
1515
from matplotlib.transforms import Affine2D
16-
from matplotlib.textpath import TextPath
16+
from matplotlib.text import TextPath
1717
from matplotlib.colors import Normalize
1818

1919
SUCCESS_SYMBOLS = [

examples/misc/logos2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import matplotlib.cm as cm
1212
import matplotlib.font_manager
1313
from matplotlib.patches import Rectangle, PathPatch
14-
from matplotlib.textpath import TextPath
14+
from matplotlib.text import TextPath
1515
import matplotlib.transforms as mtrans
1616

1717
MPL_BLUE = '#11557c'

examples/text_labels_and_annotations/demo_text_path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Using a text as a Path
44
======================
55
6-
`~matplotlib.textpath.TextPath` creates a `.Path` that is the outline of the
6+
`~matplotlib.text.TextPath` creates a `.Path` that is the outline of the
77
characters of a text. The resulting path can be employed e.g. as a clip path
88
for an image.
99
"""

lib/matplotlib/backend_bases.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
import matplotlib as mpl
4545
from matplotlib import (
46-
_api, backend_tools as tools, cbook, colors, _docstring, textpath,
46+
_api, backend_tools as tools, cbook, colors, _docstring, text,
4747
_tight_bbox, transforms, widgets, get_backend, is_interactive, rcParams)
4848
from matplotlib._pylab_helpers import Gcf
4949
from matplotlib.backend_managers import ToolManager
@@ -172,7 +172,7 @@ class RendererBase:
172172
def __init__(self):
173173
super().__init__()
174174
self._texmanager = None
175-
self._text2path = textpath.TextToPath()
175+
self._text2path = text.TextToPath()
176176
self._raster_depth = 0
177177
self._rasterizing = False
178178

@@ -515,7 +515,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
515515
The y location of the text baseline in display coords.
516516
s : str
517517
The TeX text string.
518-
prop : `matplotlib.font_manager.FontProperties`
518+
prop : `~matplotlib.font_manager.FontProperties`
519519
The font properties.
520520
angle : float
521521
The rotation angle in degrees anti-clockwise.
@@ -538,12 +538,12 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
538538
The y location of the text baseline in display coords.
539539
s : str
540540
The text string.
541-
prop : `matplotlib.font_manager.FontProperties`
541+
prop : `~matplotlib.font_manager.FontProperties`
542542
The font properties.
543543
angle : float
544544
The rotation angle in degrees anti-clockwise.
545545
ismath : bool or "TeX"
546-
If True, use mathtext parser. If "TeX", use *usetex* mode.
546+
If True, use mathtext parser. If "TeX", use tex for rendering.
547547
mtext : `matplotlib.text.Text`
548548
The original text object to be rendered.
549549
@@ -569,12 +569,18 @@ def _get_text_path_transform(self, x, y, s, prop, angle, ismath):
569569
570570
Parameters
571571
----------
572-
prop : `matplotlib.font_manager.FontProperties`
573-
The font property.
572+
x : float
573+
The x location of the text in display coords.
574+
y : float
575+
The y location of the text baseline in display coords.
574576
s : str
575577
The text to be converted.
578+
prop : `~matplotlib.font_manager.FontProperties`
579+
The font property.
580+
angle : float
581+
Angle in degrees to render the text at.
576582
ismath : bool or "TeX"
577-
If True, use mathtext parser. If "TeX", use *usetex* mode.
583+
If True, use mathtext parser. If "TeX", use tex for rendering.
578584
"""
579585

580586
text2path = self._text2path
@@ -599,18 +605,22 @@ def _get_text_path_transform(self, x, y, s, prop, angle, ismath):
599605

600606
def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath):
601607
"""
602-
Draw the text by converting them to paths using textpath module.
608+
Draw the text by converting them to paths using `.TextToPath`.
603609
604610
Parameters
605611
----------
606-
prop : `matplotlib.font_manager.FontProperties`
607-
The font property.
612+
x : float
613+
The x location of the text in display coords.
614+
y : float
615+
The y location of the text baseline in display coords.
608616
s : str
609617
The text to be converted.
610-
usetex : bool
611-
Whether to use usetex mode.
618+
prop : `~matplotlib.font_manager.FontProperties`
619+
The font property.
620+
angle : float
621+
Angle in degrees to render the text at.
612622
ismath : bool or "TeX"
613-
If True, use mathtext parser. If "TeX", use *usetex* mode.
623+
If True, use mathtext parser. If "TeX", use tex for rendering.
614624
"""
615625
path, transform = self._get_text_path_transform(
616626
x, y, s, prop, angle, ismath)

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,18 +1050,7 @@ def _adjust_char_id(self, char_id):
10501050
return char_id.replace("%20", "_")
10511051

10521052
def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath, mtext=None):
1053-
"""
1054-
Draw the text by converting them to paths using the textpath module.
1055-
1056-
Parameters
1057-
----------
1058-
s : str
1059-
text to be converted
1060-
prop : `matplotlib.font_manager.FontProperties`
1061-
font property
1062-
ismath : bool
1063-
If True, use mathtext parser. If "TeX", use *usetex* mode.
1064-
"""
1053+
# docstring inherited
10651054
writer = self.writer
10661055

10671056
writer.comment(s)

lib/matplotlib/markers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,11 +516,11 @@ def _set_tuple_marker(self):
516516

517517
def _set_mathtext_path(self):
518518
"""
519-
Draw mathtext markers '$...$' using TextPath object.
519+
Draw mathtext markers '$...$' using `.TextPath` object.
520520
521521
Submitted by tcb
522522
"""
523-
from matplotlib.textpath import TextPath
523+
from matplotlib.text import TextPath
524524

525525
# again, the properties could be initialised just once outside
526526
# this function

lib/matplotlib/text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from .artist import Artist
1616
from .font_manager import FontProperties
1717
from .patches import FancyArrowPatch, FancyBboxPatch, Rectangle
18-
from .textpath import TextPath # noqa # Unused, but imported by others.
18+
from .textpath import TextPath, TextToPath # noqa # Logically located here
1919
from .transforms import (
2020
Affine2D, Bbox, BboxBase, BboxTransformTo, IdentityTransform, Transform)
2121

lib/matplotlib/textpath.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def get_text_path(self, prop, s, ismath=False):
100100
from those::
101101
102102
from matplotlib.path import Path
103-
from matplotlib.textpath import TextToPath
103+
from matplotlib.text import TextToPath
104104
from matplotlib.font_manager import FontProperties
105105
106106
fp = FontProperties(family="Humor Sans", style="italic")
@@ -341,7 +341,7 @@ def __init__(self, xy, s, size=None, prop=None,
341341
The following creates a path from the string "ABC" with Helvetica
342342
font face; and another path from the latex fraction 1/2::
343343
344-
from matplotlib.textpath import TextPath
344+
from matplotlib.text import TextPath
345345
from matplotlib.font_manager import FontProperties
346346
347347
fp = FontProperties(family="Helvetica", style="italic")

lib/mpl_toolkits/axes_grid1/anchored_artists.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,22 +340,22 @@ def __init__(self, transform, label_x, label_y, length=0.15,
340340
back_length : float, default: 0.15
341341
Fraction of the arrow behind the arrow crossing.
342342
head_width : float, default: 10
343-
Width of arrow head, sent to ArrowStyle.
343+
Width of arrow head, sent to `.ArrowStyle`.
344344
head_length : float, default: 15
345-
Length of arrow head, sent to ArrowStyle.
345+
Length of arrow head, sent to `.ArrowStyle`.
346346
tail_width : float, default: 2
347-
Width of arrow tail, sent to ArrowStyle.
347+
Width of arrow tail, sent to `.ArrowStyle`.
348348
text_props, arrow_props : dict
349-
Properties of the text and arrows, passed to
350-
`~.textpath.TextPath` and `~.patches.FancyArrowPatch`.
349+
Properties of the text and arrows, passed to `.TextPath` and
350+
`.FancyArrowPatch`.
351351
**kwargs
352352
Keyword arguments forwarded to `.AnchoredOffsetbox`.
353353
354354
Attributes
355355
----------
356356
arrow_x, arrow_y : `~matplotlib.patches.FancyArrowPatch`
357357
Arrow x and y
358-
text_path_x, text_path_y : `~matplotlib.textpath.TextPath`
358+
text_path_x, text_path_y : `~matplotlib.text.TextPath`
359359
Path for arrow labels
360360
p_x, p_y : `~matplotlib.patches.PathPatch`
361361
Patch for arrow labels

0 commit comments

Comments
 (0)