-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: axes3d.py's _on_move() converts the roll angle to radians, but then passes it to view_init() as if it were still in degrees #28256
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
Labels
Milestone
Comments
MischaMegens2
added a commit
to MischaMegens2/matplotlib
that referenced
this issue
May 19, 2024
Pass roll angle to view_init() in degrees (not radians)
MischaMegens2
added a commit
to MischaMegens2/matplotlib
that referenced
this issue
May 22, 2024
Add tests for roll (test_axes3d_roll), for rotation using the mouse (test_rotate), and for rotation using the mouse when roll is nonzero (test_rotate_roll). The latter fails if the roll angle is passed with wrong units (issue matplotlib#28256).
MischaMegens2
added a commit
to MischaMegens2/matplotlib
that referenced
this issue
May 22, 2024
Add tests for rotation using the mouse (test_rotate), with and without roll. The test with nonzero roll fails if the roll angle is passed with wrong units (issue matplotlib#28256).
oscargus
added a commit
that referenced
this issue
May 24, 2024
Correct roll angle units, issue #28256
meeseeksmachine
pushed a commit
to meeseeksmachine/matplotlib
that referenced
this issue
May 24, 2024
LorenzoPeri17
pushed a commit
to LorenzoPeri17/matplotlib
that referenced
this issue
Jul 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug summary
In \lib\mpl_toolkits\mplot3d\axes3d.py,
_on_move()
deals with rotation of 3d axes using the mouse. In line 1522, the roll angle (in degrees) is converted to radians:roll = np.deg2rad(self.roll)
This roll in radians is used to calculate a new elevation and azimuth, like so:
A moment later, the view is updated:
However,
view_init()
expects its parameters to be in degrees, not radians. As a consequence, the roll now diminishes by a factor pi/180 with every mouse movement. Not intended.Code for reproduction
Actual outcome
The figure orientation has jumped to roll=0, after trying to rotate it only slightly by dragging the mouse:

Expected outcome
The figure is close to its original orientation (before dragging the mouse), at roll=45:

Additional information
Fix: add a line:
roll = self.roll
right after updating
elev
andazim
(i.e., after line 1526).Operating system
All, presumably; but I noticed it on Windows
Matplotlib Version
3.10.0.dev191+ge5af947d1b.d20240517
Matplotlib Backend
tkagg
Python version
Python 3.12.3
Jupyter version
No response
Installation
pip
The text was updated successfully, but these errors were encountered: