Skip to content

Commit 65044a2

Browse files
authored
Merge pull request #24932 from dstansby/auto-backport-of-pr-24783-on-v3.6.x
"Backport PR #24783 on branch v3.6.x (inset locator fix with tests added)"
2 parents 49aa465 + 5e2bf2c commit 65044a2

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/mpl_toolkits/axes_grid1/inset_locator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __call__(self, ax, renderer):
7878

7979
px, py = self.get_offset(width, height, 0, 0, renderer)
8080
bbox_canvas = Bbox.from_bounds(px, py, width, height)
81-
tr = ax.figure.transFigure.inverted()
81+
tr = ax.figure.transSubfigure.inverted()
8282
bb = TransformedBbox(bbox_canvas, tr)
8383

8484
return bb

lib/mpl_toolkits/tests/test_axes_grid1.py

+20
Original file line numberDiff line numberDiff line change
@@ -579,3 +579,23 @@ def test_removal():
579579
fig.canvas.draw()
580580
col.remove()
581581
fig.canvas.draw()
582+
583+
584+
@image_comparison(['anchored_locator_base_call.png'], style="mpl20")
585+
def test_anchored_locator_base_call():
586+
fig = plt.figure(figsize=(3, 3))
587+
fig1, fig2 = fig.subfigures(nrows=2, ncols=1)
588+
589+
ax = fig1.subplots()
590+
ax.set(aspect=1, xlim=(-15, 15), ylim=(-20, 5))
591+
ax.set(xticks=[], yticks=[])
592+
593+
Z = cbook.get_sample_data(
594+
"axes_grid/bivariate_normal.npy", np_load=True
595+
)
596+
extent = (-3, 4, -4, 3)
597+
598+
axins = zoomed_inset_axes(ax, zoom=2, loc="upper left")
599+
axins.set(xticks=[], yticks=[])
600+
601+
axins.imshow(Z, extent=extent, origin="lower")

0 commit comments

Comments
 (0)