Skip to content

Commit 608dc00

Browse files
committed
TST: Axes.indicate_inset failure
See #14275 inset_ax argument is meant to be optional, but currently fails if not given.
1 parent 767715f commit 608dc00

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5935,6 +5935,33 @@ def test_tick_padding_tightbbox():
59355935
assert bb.y0 < bb2.y0
59365936

59375937

5938+
def test_inset():
5939+
"""Regression test: failure described in for issue #14275"""
5940+
dx, dy = 0.05, 0.05
5941+
# generate 2 2d grids for the x & y bounds
5942+
y, x = np.mgrid[slice(1, 5 + dy, dy),
5943+
slice(1, 5 + dx, dx)]
5944+
z = np.sin(x) ** 10 + np.cos(10 + y * x) * np.cos(x)
5945+
5946+
fig, ax = plt.subplots()
5947+
ax.pcolormesh(x, y, z)
5948+
ax.set_aspect(1.)
5949+
ax.apply_aspect()
5950+
# we need to apply_aspect to make the drawing below work.
5951+
5952+
xlim = [1.5, 2.15]
5953+
ylim = [2, 2.5]
5954+
5955+
rect = [xlim[0], ylim[0], xlim[1] - xlim[0], ylim[1] - ylim[0]]
5956+
5957+
rec, connectors = ax.indicate_inset(bounds=rect)
5958+
assert connectors == []
5959+
fig.canvas.draw()
5960+
xx = np.array([[1.5, 2.],
5961+
[2.15, 2.5]])
5962+
assert (np.all(rec.get_bbox().get_points() == xx))
5963+
5964+
59385965
def test_zoom_inset():
59395966
dx, dy = 0.05, 0.05
59405967
# generate 2 2d grids for the x & y bounds

0 commit comments

Comments
 (0)