Skip to content
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

Enable interactive figure resizing for webagg and nbagg backends #24083

Closed
wants to merge 3 commits into from
Closed

Conversation

zhizheng1
Copy link
Contributor

PR Summary

This PR adds support for interactively resizing figures when using WebAgg or NbAgg backends. It essentially backports the logic used in ipympl which supports the same manner of resizing (i.e. dragging the bottom right corner).

Note the same logic applies to both webagg and nbagg (via mpl.js).

Fixes #24075

PR Checklist

Tests and Styling

  • [N/A] Has pytest style unit tests (and pytest passes).
  • [N/A] Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • [N/A] New features are documented, with examples if plot related.
  • [N/A] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • [N/A] Documentation is sphinx and numpydoc compliant (the docs should build without error).
193451951-c07869c9-cb53-4e48-91d0-1fb03650d04e.mov
Screen.Recording.2022-10-03.at.3.05.19.PM.mov

@tacaswell
Copy link
Member

Can you address the style issues?

This seems reasonable to me, thank you!

@tacaswell tacaswell requested a review from QuLogic October 3, 2022 20:04
@QuLogic
Copy link
Member

QuLogic commented Oct 3, 2022

I am confused; resizing already works in both webagg and nbagg.

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

I don't mean to discourage you, but I don't know why this needs to be done.

@tacaswell
Copy link
Member

Sorry, I was also confused as I trusted that resizing did not currently work in webagg.

@zhizheng1
Copy link
Contributor Author

zhizheng1 commented Oct 3, 2022

Could you confirm if it works? At least on Safari it's never worked for me - the div is resizable but the canvas at front is opaque and completely overlaps the div, making it unable to resize by dragging the corner. @QuLogic

I have made the changes.

@zhizheng1 zhizheng1 requested a review from QuLogic October 3, 2022 23:43
@zhizheng1
Copy link
Contributor Author

I see.. WebAgg resizing works on Chrome, but not on Safari, which I use most of the time.

Screen.Recording.2022-10-04.at.11.20.21.AM.mov
Screen.Recording.2022-10-04.at.11.21.26.AM.mov

@zhizheng1 zhizheng1 closed this Oct 7, 2022
@tacaswell
Copy link
Member

@zhizheng1 Did you mean to close this? If it fixes webagg in safari that is something we should take.

@zhizheng1
Copy link
Contributor Author

@tacaswell I think we have a better solution @QuLogic that leverages browser's built-in resizing capability instead of implementing our own. Just FYI, I also updated our patch script per this new idea (a one-liner only now!), which is shorter and more performant:

sed -i.0 -e 's/this.rubberband_canvas.ad/canvas_div.ad/g' -e 's/rubberband_canvas.ad/canvas_div.ad/g' -e 's/z-index: 1;/& pointer-events: none;/g' -e "s/+ height + 'px;'/& + 'pointer-events: none;'/g" -e 's/rubberband_canvas.st/canvas_div.st/g' ./$VENV/lib/*/*/matplotlib/*/*/*/mpl.js

Applying the above one-liner to current production MPL 3.6.0 will enable resizing in safari.

At the very least, I don't think this PR is necessary any more..

@tacaswell

This comment was marked as outdated.

@tacaswell
Copy link
Member

Sorry, I now see @QuLogic already did. 🐑 I'm still catching up on my notifications!

This is replaced by #24083.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ENH]: Resizing the figure with webagg backend by dragging the corner
4 participants