|
6 | 6 | from matplotlib import cbook
|
7 | 7 | from matplotlib.backend_bases import MouseEvent
|
8 | 8 | from matplotlib.colors import LogNorm
|
| 9 | +from matplotlib.patches import Circle, Ellipse |
9 | 10 | from matplotlib.transforms import Bbox, TransformedBbox
|
10 | 11 | from matplotlib.testing.decorators import (
|
11 | 12 | check_figures_equal, image_comparison, remove_ticks_and_titles)
|
|
15 | 16 | host_subplot, make_axes_locatable,
|
16 | 17 | Grid, AxesGrid, ImageGrid)
|
17 | 18 | from mpl_toolkits.axes_grid1.anchored_artists import (
|
18 |
| - AnchoredSizeBar, AnchoredDirectionArrows) |
| 19 | + AnchoredAuxTransformBox, AnchoredDrawingArea, AnchoredEllipse, |
| 20 | + AnchoredDirectionArrows, AnchoredSizeBar) |
19 | 21 | from mpl_toolkits.axes_grid1.axes_divider import (
|
20 | 22 | Divider, HBoxDivider, make_axes_area_auto_adjustable)
|
21 | 23 | from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
|
@@ -455,6 +457,34 @@ def on_pick(event):
|
455 | 457 | assert small in event_rects
|
456 | 458 |
|
457 | 459 |
|
| 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, color='cyan') |
| 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=-60, |
| 477 | + loc='lower left', pad=0.5, borderpad=0.4, |
| 478 | + frameon=True) |
| 479 | + ax.add_artist(ae) |
| 480 | + |
| 481 | + asb = AnchoredSizeBar(ax.transData, 0.2, r"0.2 units", loc='lower right', |
| 482 | + pad=0.3, borderpad=0.4, sep=4, fill_bar=True, |
| 483 | + frameon=False, label_top=True, prop={'size': 20}, |
| 484 | + size_vertical=0.05, color='green') |
| 485 | + ax.add_artist(asb) |
| 486 | + |
| 487 | + |
458 | 488 | def test_hbox_divider():
|
459 | 489 | arr1 = np.arange(20).reshape((4, 5))
|
460 | 490 | arr2 = np.arange(20).reshape((5, 4))
|
|
0 commit comments