FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

inset locator fix with tests added by matt256 · Pull Request #24783 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .png  (1) .py  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axes_grid1/inset_locator.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
20 changes: 20 additions & 0 deletions lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -716,3 +716,23 @@ def test_removal():
fig.canvas.draw()
col.remove()
fig.canvas.draw()


@image_comparison(['anchored_locator_base_call.png'], style="mpl20")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
@image_comparison(['anchored_locator_base_call.png'], style="mpl20")
@image_comparison(['anchored_locator_base_call.png'], style="mpl20", remove_text=True)

Or is the text a crucial part of the appearance?

(It is generally a good idea to remove the text if not needed, plus that it is cropped in this example.)

(A good approach to avoid conflicts is to insert the test at some random location in the file. This is as many insert it at the end and therefore it is more likely that there will be conflicts there. Hopefully this will be merged soon though.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@oscargus. Thank you for the feedback. I agree with your comments but i had trouble generating a test image that would pass the image comparison test when remove_text is true. I do agree, however, that the test should be for just the image and not the text. I have resubmitted the test case where I didn't put the "remove_text" but did remove all the text in the test case and generate a test image without any text.

If this isn't quite acceptable, can you provide more details on your proposed approach? Thanks!

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")

Back | FazBrowse Home | New Git URL