Skip to content

Commit

Permalink
inset locator fix with tests added
Browse files Browse the repository at this point in the history
added remove_text to image comparison decorator

Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>

removed inaccurate comments

Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>

removed text from test image and test
  • Loading branch information
matt256 committed Dec 22, 2022
1 parent 1d13d2d commit 0e801e0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axes_grid1/inset_locator.py
Expand Up @@ -73,7 +73,7 @@ def __call__(self, ax, renderer):
bbox = self.get_window_extent(renderer)
px, py = self.get_offset(bbox.width, bbox.height, 0, 0, renderer)
bbox_canvas = Bbox.from_bounds(px, py, bbox.width, bbox.height)
tr = ax.figure.transFigure.inverted()
tr = ax.figure.transSubfigure.inverted()
return TransformedBbox(bbox_canvas, tr)


Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py
Expand Up @@ -716,3 +716,38 @@ 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, height_ratios=[1, 1], squeeze=True
)

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=[])

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

# colorbar
cax = inset_axes(
axins,
width="5%",
height="100%",
loc="lower left",
bbox_to_anchor=(1.05, 0.0, 1, 1),
bbox_transform=axins.transAxes,
borderpad=0,
)

fig.colorbar(im, cax=cax, ticks=[])

0 comments on commit 0e801e0

Please sign in to comment.