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

Function test_respects_bbox

lib/matplotlib/tests/test_image.py:1205–1220  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1203
1204
1205def test_respects_bbox():
1206 fig, axs = plt.subplots(2)
1207 for ax in axs:
1208 ax.set_axis_off()
1209 im = axs[1].imshow([[0, 1], [2, 3]], aspect="auto", extent=(0, 1, 0, 1))
1210 im.set_clip_path(None)
1211 # Make the image invisible in axs[1], but visible in axs[0] if we pan
1212 # axs[1] up.
1213 im.set_clip_box(axs[0].bbox)
1214 buf_before = io.BytesIO()
1215 fig.savefig(buf_before, format="rgba")
1216 assert {*buf_before.getvalue()} == {0xff} # All white.
1217 axs[1].set(ylim=(-1, 0))
1218 buf_after = io.BytesIO()
1219 fig.savefig(buf_after, format="rgba")
1220 assert buf_before.getvalue() != buf_after.getvalue() # Not all white.
1221
1222
1223@check_figures_equal(extensions=['png', 'pdf', 'svg'])

Callers

nothing calls this directly

Calls 7

imshowMethod · 0.80
subplotsMethod · 0.45
set_axis_offMethod · 0.45
set_clip_pathMethod · 0.45
set_clip_boxMethod · 0.45
savefigMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…