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

Skip to content

Commit d544e2a

Browse files
committed
Add tests for mpl_toolkit anchored artists
1 parent 2171d95 commit d544e2a

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

lib/mpl_toolkits/axes_grid1/anchored_artists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __init__(self, transform, width, height, angle, loc,
164164
Ellipse patch drawn.
165165
"""
166166
self._box = AuxTransformBox(transform)
167-
self.ellipse = Ellipse((0, 0), width, height, angle)
167+
self.ellipse = Ellipse((0, 0), width, height, angle=angle)
168168
self._box.add_artist(self.ellipse)
169169

170170
super().__init__(loc, pad=pad, borderpad=borderpad, child=self._box,

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from matplotlib import cbook
77
from matplotlib.backend_bases import MouseEvent
88
from matplotlib.colors import LogNorm
9+
from matplotlib.patches import Circle, Ellipse
910
from matplotlib.transforms import Bbox, TransformedBbox
1011
from matplotlib.testing.decorators import (
1112
check_figures_equal, image_comparison, remove_ticks_and_titles)
@@ -15,7 +16,8 @@
1516
host_subplot, make_axes_locatable,
1617
Grid, AxesGrid, ImageGrid)
1718
from mpl_toolkits.axes_grid1.anchored_artists import (
18-
AnchoredSizeBar, AnchoredDirectionArrows)
19+
AnchoredAuxTransformBox, AnchoredDrawingArea, AnchoredEllipse,
20+
AnchoredDirectionArrows, AnchoredSizeBar)
1921
from mpl_toolkits.axes_grid1.axes_divider import (
2022
Divider, HBoxDivider, make_axes_area_auto_adjustable)
2123
from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
@@ -455,6 +457,36 @@ def on_pick(event):
455457
assert small in event_rects
456458

457459

460+
@image_comparison(['anchored_artists.png'], remove_text=True)
461+
def test_anchored_artists():
462+
fig, ax = plt.subplots(figsize=(3, 3))
463+
ada = AnchoredDrawingArea(40, 20, 0, 0, loc='upper right', pad=0.,
464+
frameon=False)
465+
p1 = Circle((10, 10), 10)
466+
ada.drawing_area.add_artist(p1)
467+
p2 = Circle((30, 10), 5, fc="r")
468+
ada.drawing_area.add_artist(p2)
469+
ax.add_artist(ada)
470+
471+
box = AnchoredAuxTransformBox(ax.transData, loc='upper left')
472+
el = Ellipse((0, 0), width=0.1, height=0.4, angle=30)
473+
box.drawing_area.add_artist(el)
474+
ax.add_artist(box)
475+
476+
ae = AnchoredEllipse(ax.transData, width=0.1, height=0.25, angle=0.,
477+
loc='lower left', pad=0.5, borderpad=0.4,
478+
frameon=True)
479+
ax.add_artist(ae)
480+
481+
asb = AnchoredSizeBar(ax.transData,
482+
0.2,
483+
r"0.2 units",
484+
loc='lower right',
485+
pad=0.3, borderpad=0.4, sep=4,
486+
frameon=False, label_top=True, prop={'size': 20})
487+
ax.add_artist(asb)
488+
489+
458490
def test_hbox_divider():
459491
arr1 = np.arange(20).reshape((4, 5))
460492
arr2 = np.arange(20).reshape((5, 4))

0 commit comments

Comments
 (0)