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

Function test_zoom_inset

lib/matplotlib/tests/test_axes.py:8346–8377  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8344
8345
8346def test_zoom_inset():
8347 dx, dy = 0.05, 0.05
8348 # generate 2 2d grids for the x & y bounds
8349 y, x = np.mgrid[slice(1, 5 + dy, dy),
8350 slice(1, 5 + dx, dx)]
8351 z = np.sin(x)**10 + np.cos(10 + y*x) * np.cos(x)
8352
8353 fig, ax = plt.subplots()
8354 ax.pcolormesh(x, y, z[:-1, :-1])
8355 ax.set_aspect(1.)
8356 ax.apply_aspect()
8357 # we need to apply_aspect to make the drawing below work.
8358
8359 # Make the inset_axes... Position axes coordinates...
8360 axin1 = ax.inset_axes([0.7, 0.7, 0.35, 0.35])
8361 # redraw the data in the inset axes...
8362 axin1.pcolormesh(x, y, z[:-1, :-1])
8363 axin1.set_xlim(1.5, 2.15)
8364 axin1.set_ylim(2, 2.5)
8365 axin1.set_aspect(ax.get_aspect())
8366
8367 with pytest.warns(mpl.MatplotlibDeprecationWarning):
8368 rec, connectors = ax.indicate_inset_zoom(axin1)
8369 fig.canvas.draw()
8370 assert len(connectors) == 4
8371 xx = np.array([[1.5, 2.],
8372 [2.15, 2.5]])
8373 assert np.all(rec.get_bbox().get_points() == xx)
8374 xx = np.array([[0.6325, 0.692308],
8375 [0.8425, 0.907692]])
8376 np.testing.assert_allclose(
8377 axin1.get_position().get_points(), xx, rtol=1e-4)
8378
8379
8380@image_comparison(['inset_polar.png'], remove_text=True, style='mpl20')

Callers

nothing calls this directly

Calls 13

pcolormeshMethod · 0.80
inset_axesMethod · 0.80
indicate_inset_zoomMethod · 0.80
subplotsMethod · 0.45
set_aspectMethod · 0.45
apply_aspectMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 0.45
get_aspectMethod · 0.45
drawMethod · 0.45
get_pointsMethod · 0.45
get_bboxMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…