-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fixes #20044 pass AnnotationBbox to renderer #24637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Note, issue linking belongs in the PR description or within the commit message, not the PR/commit title. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening the PR! Could you add a test to make sure the gid
is set for an AnnotationBbox
to make sure this doesn't break again in the future? I think the easiest way would be to modify the test added in #15087.
Sure thing 👍 |
|
||
fig = plt.figure() | ||
ax = fig.add_subplot() | ||
arr_img = plt.imread("annotationbbox_gid.png") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use one of our existing images?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why not
def test_annotationbbox_gid(): | ||
# Test that object gid appears in the AnnotationBbox | ||
# in output svg. | ||
from matplotlib.offsetbox import (OffsetImage, AnnotationBbox) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imports should be at the top of the file
png_path = Path(__file__).parent / \ | ||
"baseline_images\test_backend_svg\noscale.png" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paths are forward "/" on non-windows systems. Since you're already using Path
though you can just keep adding
png_path = Path(__file__).parent / \ | |
"baseline_images\test_backend_svg\noscale.png" | |
png_path = Path(__file__).parent / \ | |
"baseline_images" / "test_backend_svg" / "noscale.png" |
with that being said though, I'm not sure you even need to load an image here since you aren't doing an image comparison? So, perhaps just pass a 2d array to the OffsetImage below.
arr_img = np.ones((32, 32))
This needs to be rebased / squashed (the failure is that a file was added and then removed in the history so we need to re-write history to avoid that), othewise looks good 👍🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modulo squashing the commits
This should be squashed when merging. |
PR Summary
Apply the fix from #15087 to the AnnotationBbox so the artist gid associated with each image can be accessed when saved to an svg.
PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst