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

Skip to content

Commit 3fa8f1e

Browse files
committed
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).
1 parent 886983d commit 3fa8f1e

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
API changes and deprecations
2+
````````````````````````````
3+
4+
``axisartist.axis_artist.BezierPath`` is deprecated (use `.patches.PathPatch`
5+
to draw arbitrary Paths).
6+
7+
``AxisArtist.line`` is now a `.patches.PathPatch` instance instead of a
8+
``BezierPath`` instance.

lib/matplotlib/patches.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,9 @@ def __init__(self, path, **kwargs):
941941
def get_path(self):
942942
return self._path
943943

944+
def set_path(self, path):
945+
self._path = path
946+
944947

945948
class Polygon(Patch):
946949
"""

lib/mpl_toolkits/axisartist/axis_artist.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,15 @@
9696
from matplotlib.artist import Artist
9797
from matplotlib.collections import LineCollection
9898
from matplotlib.lines import Line2D
99+
from matplotlib.patches import PathPatch
99100
from matplotlib.path import Path
100101
from matplotlib.transforms import (
101102
Affine2D, Bbox, IdentityTransform, ScaledTranslation, TransformedPath)
102103

103104
from .axisline_style import AxislineStyle
104105

105106

107+
@cbook.deprecated("3.2", alternative="matplotlib.patches.PathPatch")
106108
class BezierPath(Line2D):
107109

108110
def __init__(self, path, *args, **kwargs):
@@ -926,10 +928,13 @@ def _init_line(self):
926928

927929
axisline_style = self.get_axisline_style()
928930
if axisline_style is None:
929-
self.line = BezierPath(
931+
self.line = PathPatch(
930932
self._axis_artist_helper.get_line(self.axes),
931933
color=rcParams['axes.edgecolor'],
934+
fill=False,
932935
linewidth=rcParams['axes.linewidth'],
936+
capstyle=rcParams['lines.solid_capstyle'],
937+
joinstyle=rcParams['lines.solid_joinstyle'],
933938
transform=tran)
934939
else:
935940
self.line = axisline_style(self, transform=tran)

0 commit comments

Comments
 (0)