ENH: Snap 3D view angle changes when holding Control key#31145
ENH: Snap 3D view angle changes when holding Control key#31145timhoffm merged 21 commits intomatplotlib:mainfrom
Conversation
5b91598 to
2f47b9a
Compare
|
This works really nicely! A few things to add to this:
|
3ac4e08 to
bae4094
Compare
|
@scottshambaugh I have also made the corresponding changes in other required files axes3d.py and test file too. |
|
Could you push what you have right now so I can see the code changes? |
|
@scottshambaugh |
scottshambaugh
left a comment
There was a problem hiding this comment.
Left some comments, to fix the error you're seeing you'll need to add the new rcparam to the list in lib/matplotlib/typing.py around line 225. The instructions we have for adding new params aren't great, we should probably document that better to make it easier.
|
@scottshambaugh |
|
Hi @Chirag3841, I don't see those changes pushed up yet. |
I have done that in the last commit which caused multiple errors where 2 nd pic is of test file and remaining of axes3d.py FAILED lib/mpl_toolkits/mplot3d/tests/test_axes3d.py::test_ctrl_rotation_snaps_to_5deg - KeyError: 'elev' |
|
@scottshambaugh I resolved that issues in recent PR but still getting valid rc parameter error on local |
|
@scottshambaugh I changed the test file code and added what's a new doc too. |
scottshambaugh
left a comment
There was a problem hiding this comment.
Ok, this looks good to me now! The test failures look unrelated, so no need to worry about those.
|
@scottshambaugh Thanks for your review and support. |
|
Any Update ? |
|
We require 2 maintainers to approve each PR that changes code, so it may take a bit for someone else to look at this. |
Thanks for the clarification |
|
Should we support a tuple so that we can set individual snap angles for (elev / azim / roll)? Also, would a special value make sense to lock that angle? That way, one could e.g. limit the rotation to azim and keep elev and roll fixed. But not sure whether this should be folded into snap. |
|
@timhoffm That’s an interesting idea but per-angle snapping or locking could potentially be explored separately if we think it warrants expanding the API. |
|
Well, it potentially touches a design decision: If we want per-angle snapping, we'd need to support three-component config Then we can decide whether we additional want to allow single-component and implicitly broadcast. This is a trade-off: convenience vs. a more complex API and handling logic. It's not worlds difference but something that we only have the freedom to decide before this is released. I'm slightly on side of always requiring the three values. It's that cumbersome to write them out if one really cares to configure snap. |
|
@timhoffm I feel that keeping it as a single float keeps the API simpler and likely covers the most common use case. |
|
My ask for making this angle an rcparam was more for wanting to avoid magic constants than anything else. I could see people wanting to make it e.g. 1 deg rather than 5, but think the per-axis snapping values is going to be used rarely if ever. IMO keeping this simple with a single value is best. |
|
Ok, if the expectation is that individal angle steps are not needed, let's merge as is. |
|
Thanks @scottshambaugh and @timhoffm for reviewing and supporting this PR. |
PR: matplotlib#31145 Issue: matplotlib#31093 Base commit: cb63559 Changed lines: 92





PR summary
PR checklist
Description
This PR adds a Ctrl modifier key to 3D mouse rotation so that when Ctrl is held while dragging, the view angles snap to fixed 5° increments (azimuth/elevation/roll). This makes it easier to return to repeatable camera angles when exploring 3D plots.
A small test is included to verify snapping behavior when Ctrl is pressed.