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

Skip to content

Commit 0022f42

Browse files
authored
Merge pull request #25781 from anntzer/ae
Deprecate AnchoredEllipse.
2 parents 301b651 + 20c3c56 commit 0022f42

File tree

4 files changed

+11
-17
lines changed

4 files changed

+11
-17
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``AnchoredEllipse`` is deprecated
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
Instead, directly construct an `.AnchoredOffsetbox`, an `.AuxTransformBox`, and an
4+
`~.patches.Ellipse`, as demonstrated in :doc:`/gallery/misc/anchored_artists`.

galleries/examples/axes_grid1/simple_anchored_artists.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,6 @@ def draw_circle(ax):
4646
ax.add_artist(ada)
4747

4848

49-
def draw_ellipse(ax):
50-
"""
51-
Draw an ellipse of width=0.1, height=0.15 in data coordinates
52-
"""
53-
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredEllipse
54-
ae = AnchoredEllipse(ax.transData, width=0.1, height=0.15, angle=0.,
55-
loc='lower left', pad=0.5, borderpad=0.4,
56-
frameon=True)
57-
58-
ax.add_artist(ae)
59-
60-
6149
def draw_sizebar(ax):
6250
"""
6351
Draw a horizontal bar with length of 0.1 in data coordinates,
@@ -78,7 +66,6 @@ def draw_sizebar(ax):
7866

7967
draw_text(ax)
8068
draw_circle(ax)
81-
draw_ellipse(ax)
8269
draw_sizebar(ax)
8370

8471
plt.show()

lib/mpl_toolkits/axes_grid1/anchored_artists.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from matplotlib import transforms
1+
from matplotlib import _api, transforms
22
from matplotlib.offsetbox import (AnchoredOffsetbox, AuxTransformBox,
33
DrawingArea, TextArea, VPacker)
44
from matplotlib.patches import (Rectangle, Ellipse, ArrowStyle,
@@ -124,6 +124,7 @@ def __init__(self, transform, loc,
124124
**kwargs)
125125

126126

127+
@_api.deprecated("3.8")
127128
class AnchoredEllipse(AnchoredOffsetbox):
128129
def __init__(self, transform, width, height, angle, loc,
129130
pad=0.1, borderpad=0.1, prop=None, frameon=True, **kwargs):

lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,11 @@ def test_anchored_artists():
526526
box.drawing_area.add_artist(el)
527527
ax.add_artist(box)
528528

529-
ae = AnchoredEllipse(ax.transData, width=0.1, height=0.25, angle=-60,
530-
loc='lower left', pad=0.5, borderpad=0.4,
531-
frameon=True)
529+
# Manually construct the ellipse instead, once the deprecation elapses.
530+
with pytest.warns(mpl.MatplotlibDeprecationWarning):
531+
ae = AnchoredEllipse(ax.transData, width=0.1, height=0.25, angle=-60,
532+
loc='lower left', pad=0.5, borderpad=0.4,
533+
frameon=True)
532534
ax.add_artist(ae)
533535

534536
asb = AnchoredSizeBar(ax.transData, 0.2, r"0.2 units", loc='lower right',

0 commit comments

Comments
 (0)