diff --git a/doc/api/next_api_changes/deprecations/23565-OG.rst b/doc/api/next_api_changes/deprecations/23565-OG.rst new file mode 100644 index 000000000000..fa9c26a321e0 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/23565-OG.rst @@ -0,0 +1,7 @@ +Alternative import location for ``TextPath`` and ``AxislineStyle`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +These two classes have historically sometimes been imported from incorrect +locations. This is now deprecated and `.TextPath` should be imported from +`matplotlib.textpath`, while `AxislineStyle` should be imported from +`mpl_toolkit.axisartist.axisline_style`. diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index a59dde4706d7..d54f10978185 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -15,7 +15,7 @@ from .artist import Artist from .font_manager import FontProperties from .patches import FancyArrowPatch, FancyBboxPatch, Rectangle -from .textpath import TextPath # Unused, but imported by others. +from .textpath import TextPath as _TextPath # Unused, but imported by others. from .transforms import ( Affine2D, Bbox, BboxBase, BboxTransformTo, IdentityTransform, Transform) @@ -23,6 +23,12 @@ _log = logging.getLogger(__name__) +@_api.deprecated("3.6", message="Since %(since)s, %(name)s should be imported " + "from its correct module: matplotlib.textpath") +class TextPath(_TextPath): + pass + + @_api.deprecated("3.6") def get_rotation(rotation): """ diff --git a/lib/mpl_toolkits/axes_grid1/anchored_artists.py b/lib/mpl_toolkits/axes_grid1/anchored_artists.py index a3f59a2ef2ee..e72aace4e041 100644 --- a/lib/mpl_toolkits/axes_grid1/anchored_artists.py +++ b/lib/mpl_toolkits/axes_grid1/anchored_artists.py @@ -3,7 +3,7 @@ DrawingArea, TextArea, VPacker) from matplotlib.patches import (Rectangle, Ellipse, ArrowStyle, FancyArrowPatch, PathPatch) -from matplotlib.text import TextPath +from matplotlib.textpath import TextPath __all__ = ['AnchoredDrawingArea', 'AnchoredAuxTransformBox', 'AnchoredEllipse', 'AnchoredSizeBar', 'AnchoredDirectionArrows'] diff --git a/lib/mpl_toolkits/axisartist/axislines.py b/lib/mpl_toolkits/axisartist/axislines.py index d62ab7eb0b23..ba0b5c5d6495 100644 --- a/lib/mpl_toolkits/axisartist/axislines.py +++ b/lib/mpl_toolkits/axisartist/axislines.py @@ -46,10 +46,17 @@ import matplotlib.axes as maxes from matplotlib.path import Path from mpl_toolkits.axes_grid1 import mpl_axes -from .axisline_style import AxislineStyle +from .axisline_style import AxislineStyle as _AxislineStyle from .axis_artist import AxisArtist, GridlinesCollection +@_api.deprecated("3.6", message="Since %(since)s, %(name)s should be imported " + "from its correct module: " + "mpl_toolkits.axisartist.axisline_style") +class AxislineStyle(_AxislineStyle): + pass + + class AxisArtistHelper: """ AxisArtistHelper should define