()
| 18 | |
| 19 | @image_comparison(['offsetbox_clipping'], remove_text=True, style='_classic_test') |
| 20 | def test_offsetbox_clipping(): |
| 21 | # - create a plot |
| 22 | # - put an AnchoredOffsetbox with a child DrawingArea |
| 23 | # at the center of the axes |
| 24 | # - give the DrawingArea a gray background |
| 25 | # - put a black line across the bounds of the DrawingArea |
| 26 | # - see that the black line is clipped to the edges of |
| 27 | # the DrawingArea. |
| 28 | fig, ax = plt.subplots() |
| 29 | size = 100 |
| 30 | da = DrawingArea(size, size, clip=True) |
| 31 | assert da.clip_children |
| 32 | bg = mpatches.Rectangle((0, 0), size, size, |
| 33 | facecolor='#CCCCCC', |
| 34 | edgecolor='None', |
| 35 | linewidth=0) |
| 36 | line = mlines.Line2D([-size*.5, size*1.5], [size/2, size/2], |
| 37 | color='black', |
| 38 | linewidth=10) |
| 39 | anchored_box = AnchoredOffsetbox( |
| 40 | loc='center', |
| 41 | child=da, |
| 42 | pad=0., |
| 43 | frameon=False, |
| 44 | bbox_to_anchor=(.5, .5), |
| 45 | bbox_transform=ax.transAxes, |
| 46 | borderpad=0.) |
| 47 | |
| 48 | da.add_artist(bg) |
| 49 | da.add_artist(line) |
| 50 | ax.add_artist(anchored_box) |
| 51 | ax.set_xlim(0, 1) |
| 52 | ax.set_ylim(0, 1) |
| 53 | |
| 54 | |
| 55 | def test_offsetbox_clip_children(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…