|
7 | 7 | frommatplotlibimport_api,cbook
|
8 | 8 | frommatplotlib.backend_basesimportMouseEvent
|
9 | 9 | frommatplotlib.colorsimportLogNorm
|
| 10 | +frommatplotlib.patchesimportCircle,Ellipse |
10 | 11 | frommatplotlib.transformsimportBbox,TransformedBbox
|
11 | 12 | frommatplotlib.testing.decoratorsimport (
|
12 | 13 | check_figures_equal,image_comparison,remove_ticks_and_titles)
|
|
16 | 17 | host_subplot,make_axes_locatable,
|
17 | 18 | Grid,AxesGrid,ImageGrid)
|
18 | 19 | frommpl_toolkits.axes_grid1.anchored_artistsimport (
|
19 |
| -AnchoredSizeBar,AnchoredDirectionArrows) |
| 20 | +AnchoredAuxTransformBox,AnchoredDrawingArea,AnchoredEllipse, |
| 21 | +AnchoredDirectionArrows,AnchoredSizeBar) |
20 | 22 | frommpl_toolkits.axes_grid1.axes_dividerimport (
|
21 | 23 | Divider,HBoxDivider,make_axes_area_auto_adjustable,SubplotDivider,
|
22 | 24 | VBoxDivider)
|
@@ -508,6 +510,34 @@ def on_pick(event):
|
508 | 510 | assertsmallinevent_rects
|
509 | 511 |
|
510 | 512 |
|
| 513 | +@image_comparison(['anchored_artists.png'],remove_text=True,style='mpl20') |
| 514 | +deftest_anchored_artists(): |
| 515 | +fig,ax=plt.subplots(figsize=(3,3)) |
| 516 | +ada=AnchoredDrawingArea(40,20,0,0,loc='upper right',pad=0., |
| 517 | +frameon=False) |
| 518 | +p1=Circle((10,10),10) |
| 519 | +ada.drawing_area.add_artist(p1) |
| 520 | +p2=Circle((30,10),5,fc="r") |
| 521 | +ada.drawing_area.add_artist(p2) |
| 522 | +ax.add_artist(ada) |
| 523 | + |
| 524 | +box=AnchoredAuxTransformBox(ax.transData,loc='upper left') |
| 525 | +el=Ellipse((0,0),width=0.1,height=0.4,angle=30,color='cyan') |
| 526 | +box.drawing_area.add_artist(el) |
| 527 | +ax.add_artist(box) |
| 528 | + |
| 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) |
| 532 | +ax.add_artist(ae) |
| 533 | + |
| 534 | +asb=AnchoredSizeBar(ax.transData,0.2,r"0.2 units",loc='lower right', |
| 535 | +pad=0.3,borderpad=0.4,sep=4,fill_bar=True, |
| 536 | +frameon=False,label_top=True,prop={'size':20}, |
| 537 | +size_vertical=0.05,color='green') |
| 538 | +ax.add_artist(asb) |
| 539 | + |
| 540 | + |
511 | 541 | deftest_hbox_divider():
|
512 | 542 | arr1=np.arange(20).reshape((4,5))
|
513 | 543 | arr2=np.arange(20).reshape((5,4))
|
|