MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_offsetbox_clipping

Function test_offsetbox_clipping

lib/matplotlib/tests/test_offsetbox.py:20–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18
19@image_comparison(['offsetbox_clipping'], remove_text=True, style='_classic_test')
20def 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
55def test_offsetbox_clip_children():

Callers

nothing calls this directly

Calls 7

add_artistMethod · 0.95
DrawingAreaClass · 0.90
AnchoredOffsetboxClass · 0.90
subplotsMethod · 0.45
add_artistMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…