Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ENH]: mplot3d mouse rotation style #28408

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

Closed
MischaMegens2 opened this issue Jun 17, 2024 · 7 comments · Fixed by #28841
Closed

[ENH]: mplot3d mouse rotation style #28408

MischaMegens2 opened this issue Jun 17, 2024 · 7 comments · Fixed by #28841

Comments

@MischaMegens2
Copy link
Contributor

Problem

PR #28290 introduced more natural 3D rotation with the mouse. It uses a variation on Ken Shoemake's Arcball (it doesn't spin at double the mouse speed); however, this variation spoils a nice feature of the original Arcball (as Scott Shambaugh pointed out): if you move the mouse back the original point on the screen, this would return the view to the original view.

It would be desirable to be able to choose what kind of mouse rotation style one wants (Ken Shoemake's original Arcball, or the not-the-double-speed variation of the PR, or Holroyd's arcball, or a Trackball, or indeed the original matplotlib style which does not control roll, much like in matlab).

Proposed solution

Make the mouse rotation style selectable using rcParams. Perhaps axes3d.mouserotation ?

@timhoffm
Copy link
Member

timhoffm commented Jun 17, 2024

I'm not an expert in this topic, so do we really need all those impementations? I assume 99% of users just want that "it works", which means one good rotation style should be enough.

@MischaMegens2
Copy link
Contributor Author

I'm not an expert in this topic, so do we really need all those imp[l]ementations? I assume 99% of users just want that "it works", which means one good rotation style should be enough.

I was originally of this opinion too - see #28290 (comment).
But I can see Scott's point; and there are legitimate trade-offs between various mouse rotation styles. With a few lines extra code we could accommodate the various preferences.
As for the 99% of users, they will have the default style and it will "just work" for them.

@scottshambaugh
Copy link
Contributor

this variation spoils a nice feature of the original Arcball (as Scott Shambaugh pointed out): if you move the mouse back the original point on the screen, this would return the view to the original view

This is the main thing I'm hoping to resolve, but I can see the different rotation modes being useful for different input devices / accessibility concerns.

@MischaMegens2
Copy link
Contributor Author

MischaMegens2 commented Jun 26, 2024

This is the main thing I'm hoping to resolve, but I can see the different rotation modes being useful for different input devices / accessibility concerns.

I have a PR in the works for it, almost ready, but I'm waiting for the merge of PR #28395, I'd prefer to finish one PR before starting another...
Could you take a look at it, or ask someone else to do so?

@astromancer
Copy link
Contributor

astromancer commented Jul 2, 2024

I would go as far as to argue that rolling the axes in 3d is an anti-feature in most cases. The gain in flexibility makes it harder to control and achieve the desired view with mouse interactions. This is especially the case when viewing data that is plotted with z-direction being physically meaningful is some way (like a 3d histogram or wireframe with size in the z-direction measuring some quantity). From a visualisation perspective, rotating in azimuth is very useful here, while rolling is actually just annoying. Therefore I think it's essential that we are able to restore the old rotation behaviour on user request. I was envisioning something like holding down CNTRL key to toggle the rotation behaviour.

@MischaMegens2
Copy link
Contributor Author

I would go as far as to argue that rolling the axes in 3d is an anti-feature in most cases. [...] Therefore I think it's essential that we are able to restore the old rotation behaviour on user request.

I take it that you are very happy with the change proposed in this Issue, then?

I was envisioning something like holding down CNTRL key to toggle the rotation behaviour.

This proposal I find puzzling - surely a CNTRL key does not mesh well with the 'principle of least surprise'? (And you want to hold it down? Or you want to toggle?)
Would a selection on the toolbar be better?

Could it be that what you really want is to constrain the roll to zero to keep the z axis parallel to the edge of the figure? That is a separate issue from having the rotation respond naturally to the mouse (i.e., move mouse to the left/right/up/down -> tilt figure to the left/right/up/down, consistently). Perhaps it deserves raising a separate Issue? (Feel free...)

@timhoffm
Copy link
Member

timhoffm commented Jul 3, 2024

Would a selection on the toolbar be better?

IMHO a rcParam for the rotation mode should be good enough (if we need multiple options). You can set this globally in your matplotlibrc, or you can set it before showing the figure. You'll hardly need to toggle different modes live.

This makes implementation much simpler.

MischaMegens2 added a commit to MischaMegens2/matplotlib that referenced this issue Sep 19, 2024
Addresses Issue matplotlib#28408
- matplotlibrc: add axes3d.mouserotationstyle and axes3d.trackballsize
- lib/matplotlib/rcsetup.py: add validation for axes3d.mouserotationstyle and axes3d.trackballsize
- axes3d.py: implement various mouse rotation styles
- update test_axes3d.py::test_rotate()
- view_angles.rst: add documentation for the mouse rotation styles
- update next_whats_new/mouse_rotation.rst
@scottshambaugh scottshambaugh linked a pull request Sep 21, 2024 that will close this issue
4 tasks
@QuLogic QuLogic added this to the v3.10.0 milestone Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants