Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2b22fe3

Browse filesBrowse files
committed
Add tests for mpl_toolkit anchored artists
1 parent 7f5335a commit 2b22fe3
Copy full SHA for 2b22fe3

File tree

Expand file treeCollapse file tree

2 files changed

+31
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+31
-1
lines changed
Loading

‎lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py
+31-1Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from matplotlib import cbook
88
from matplotlib.backend_bases import MouseEvent
99
from matplotlib.colors import LogNorm
10+
from matplotlib.patches import Circle, Ellipse
1011
from matplotlib.transforms import Bbox, TransformedBbox
1112
from matplotlib.testing.decorators import (
1213
check_figures_equal, image_comparison, remove_ticks_and_titles)
@@ -16,7 +17,8 @@
1617
host_subplot, make_axes_locatable,
1718
Grid, AxesGrid, ImageGrid)
1819
from mpl_toolkits.axes_grid1.anchored_artists import (
19-
AnchoredSizeBar, AnchoredDirectionArrows)
20+
AnchoredAuxTransformBox, AnchoredDrawingArea, AnchoredEllipse,
21+
AnchoredDirectionArrows, AnchoredSizeBar)
2022
from mpl_toolkits.axes_grid1.axes_divider import (
2123
Divider, HBoxDivider, make_axes_area_auto_adjustable, SubplotDivider,
2224
VBoxDivider)
@@ -499,6 +501,34 @@ def on_pick(event):
499501
assert small in event_rects
500502

501503

504+
@image_comparison(['anchored_artists.png'], remove_text=True, style='mpl20')
505+
def test_anchored_artists():
506+
fig, ax = plt.subplots(figsize=(3, 3))
507+
ada = AnchoredDrawingArea(40, 20, 0, 0, loc='upper right', pad=0.,
508+
frameon=False)
509+
p1 = Circle((10, 10), 10)
510+
ada.drawing_area.add_artist(p1)
511+
p2 = Circle((30, 10), 5, fc="r")
512+
ada.drawing_area.add_artist(p2)
513+
ax.add_artist(ada)
514+
515+
box = AnchoredAuxTransformBox(ax.transData, loc='upper left')
516+
el = Ellipse((0, 0), width=0.1, height=0.4, angle=30, color='cyan')
517+
box.drawing_area.add_artist(el)
518+
ax.add_artist(box)
519+
520+
ae = AnchoredEllipse(ax.transData, width=0.1, height=0.25, angle=-60,
521+
loc='lower left', pad=0.5, borderpad=0.4,
522+
frameon=True)
523+
ax.add_artist(ae)
524+
525+
asb = AnchoredSizeBar(ax.transData, 0.2, r"0.2 units", loc='lower right',
526+
pad=0.3, borderpad=0.4, sep=4, fill_bar=True,
527+
frameon=False, label_top=True, prop={'size': 20},
528+
size_vertical=0.05, color='green')
529+
ax.add_artist(asb)
530+
531+
502532
def test_hbox_divider():
503533
arr1 = np.arange(20).reshape((4, 5))
504534
arr2 = np.arange(20).reshape((5, 4))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.