From 3fa8f1e9f29565308df3e953566dbd2367b2286d Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 15 Jul 2019 11:28:26 +0200 Subject: [PATCH] Deprecate axis_artist.BezierPath. Throughout the library the advice to draw an arbitrary Path object is to use PathPatch; there's no reason to do differently with a one-off class in axisartist. Technically that's an API break because the type of AxisArtist.line changed, but most common APIs do overlap (e.g. `set_color`, which is exercised by the tests) so I'm not going to bother with a deprecation period which would be quite painful (likely involving a global rcParam controlling the switch from the old API to the new one). --- doc/api/next_api_changes/2019-07-15-AL.rst | 8 ++++++++ lib/matplotlib/patches.py | 3 +++ lib/mpl_toolkits/axisartist/axis_artist.py | 7 ++++++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 doc/api/next_api_changes/2019-07-15-AL.rst diff --git a/doc/api/next_api_changes/2019-07-15-AL.rst b/doc/api/next_api_changes/2019-07-15-AL.rst new file mode 100644 index 000000000000..6fac8917ae20 --- /dev/null +++ b/doc/api/next_api_changes/2019-07-15-AL.rst @@ -0,0 +1,8 @@ +API changes and deprecations +```````````````````````````` + +``axisartist.axis_artist.BezierPath`` is deprecated (use `.patches.PathPatch` +to draw arbitrary Paths). + +``AxisArtist.line`` is now a `.patches.PathPatch` instance instead of a +``BezierPath`` instance. diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 6458487a6eb4..c648611608d2 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -941,6 +941,9 @@ def __init__(self, path, **kwargs): def get_path(self): return self._path + def set_path(self, path): + self._path = path + class Polygon(Patch): """ diff --git a/lib/mpl_toolkits/axisartist/axis_artist.py b/lib/mpl_toolkits/axisartist/axis_artist.py index b81340054e7f..49220df9bd63 100644 --- a/lib/mpl_toolkits/axisartist/axis_artist.py +++ b/lib/mpl_toolkits/axisartist/axis_artist.py @@ -96,6 +96,7 @@ from matplotlib.artist import Artist from matplotlib.collections import LineCollection from matplotlib.lines import Line2D +from matplotlib.patches import PathPatch from matplotlib.path import Path from matplotlib.transforms import ( Affine2D, Bbox, IdentityTransform, ScaledTranslation, TransformedPath) @@ -103,6 +104,7 @@ from .axisline_style import AxislineStyle +@cbook.deprecated("3.2", alternative="matplotlib.patches.PathPatch") class BezierPath(Line2D): def __init__(self, path, *args, **kwargs): @@ -926,10 +928,13 @@ def _init_line(self): axisline_style = self.get_axisline_style() if axisline_style is None: - self.line = BezierPath( + self.line = PathPatch( self._axis_artist_helper.get_line(self.axes), color=rcParams['axes.edgecolor'], + fill=False, linewidth=rcParams['axes.linewidth'], + capstyle=rcParams['lines.solid_capstyle'], + joinstyle=rcParams['lines.solid_joinstyle'], transform=tran) else: self.line = axisline_style(self, transform=tran)