Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.2k
Add URL support for images in PDF backend#23454
Add URL support for images in PDF backend#23454oscargus wants to merge 1 commit intomatplotlib:mainfrom
Conversation
oscargus commentedJul 21, 2022
oscargus commentedJul 21, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Case 2 solved. Remaining problems:
So for now I am pretty happy with it for now. |
f6e34a6 tod401c1cCompare
QuLogic left a comment
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.
Have not read the code yet.
| The PDF backend can now generate clickable images if a URL is provided to the | ||
| image. There are a few limitations worth noting though: | ||
| * If parts of the image are clipped, the non-visible parts are still clickable. |
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.
Does this mean, if you zoom in on the image, parts outside the Axes will be clickable?
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.
Yes. It is sort of easy to fix for non-transformed images (if there is a way to get the Axes extents from the gc(?). But for transformed it is much harder.
(I think the same holds for texts.)
| * If there are transforms applied to the image, the whole enclosing rectangle | ||
| is clickable. However, if you use ``interpolation='none'`` for the image, | ||
| only the transformed image area is clickable (depending on viewer support). |
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.
Sorry, I'm confused about what this means.
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.
First sentence: Basically, the image with the hand drawn "rectangle" above is clickable. Probably there is a better wording for it.
Second sentence: if you rely on the PDF transform (i.e. set interpolation='none' and possibly a few more conditions) the clickable area is the image. Bracket part: not all PDF viewers support that and will fall back on the red rectangle.
oscargus commentedJul 23, 2022
OK, I know how to sort out the clickable outside of Axes-thing for non-transformed images (in theory for transformed as well, but will have to think a bit further regarding how many different cases there are and how to deal with them). |
Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it. |

Uh oh!
There was an error while loading.Please reload this page.
PR Summary
Related to#23152
Currently, this doesn't work with a transform. If a standard transform is used, as inhttps://matplotlib.org/stable/gallery/images_contours_and_fields/affine_image.html it works, but the area is the "outline rectangle", rather than the exact area.
For transforms withHowever, for a plain image or a transformed withinterpolation='none'it doesn't work at all.interpolation='none'it works well.Note that one cannot use composite images (
plt.rcParams['image.composite_image']must beFalse) for this to work as the composite image doesn't have an URL set.There should be a release note outlining the limitations, but maybe I can figure out how to improve it slightly before that...
(This also includes a minor refactoring.)
PR Checklist
Tests and Styling
pytestpasses).flake8-docstringsand runflake8 --docstring-convention=all).Documentation
doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).