Skip to content

Commit

Permalink
Merge pull request #24932 from dstansby/auto-backport-of-pr-24783-on-…
Browse files Browse the repository at this point in the history
…v3.6.x

"Backport PR #24783 on branch v3.6.x (inset locator fix with tests added)"
  • Loading branch information
timhoffm committed Jan 10, 2023
2 parents 49aa465 + 5e2bf2c commit 65044a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axes_grid1/inset_locator.py
Expand Up @@ -78,7 +78,7 @@ def __call__(self, ax, renderer):

px, py = self.get_offset(width, height, 0, 0, renderer)
bbox_canvas = Bbox.from_bounds(px, py, width, height)
tr = ax.figure.transFigure.inverted()
tr = ax.figure.transSubfigure.inverted()
bb = TransformedBbox(bbox_canvas, tr)

return bb
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions lib/mpl_toolkits/tests/test_axes_grid1.py
Expand Up @@ -579,3 +579,23 @@ def test_removal():
fig.canvas.draw()
col.remove()
fig.canvas.draw()


@image_comparison(['anchored_locator_base_call.png'], style="mpl20")
def test_anchored_locator_base_call():
fig = plt.figure(figsize=(3, 3))
fig1, fig2 = fig.subfigures(nrows=2, ncols=1)

ax = fig1.subplots()
ax.set(aspect=1, xlim=(-15, 15), ylim=(-20, 5))
ax.set(xticks=[], yticks=[])

Z = cbook.get_sample_data(
"axes_grid/bivariate_normal.npy", np_load=True
)
extent = (-3, 4, -4, 3)

axins = zoomed_inset_axes(ax, zoom=2, loc="upper left")
axins.set(xticks=[], yticks=[])

axins.imshow(Z, extent=extent, origin="lower")

0 comments on commit 65044a2

Please sign in to comment.