Description
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:
delev = -(dy/h)*180*np.cos(roll) + (dx/w)*180*np.sin(roll)
dazim = -(dy/h)*180*np.sin(roll) - (dx/w)*180*np.cos(roll)
elev = self.elev + delev
azim = self.azim + dazim
A moment later, the view is updated:
self.view_init(
elev=elev,
azim=azim,
roll=roll,
vertical_axis=vertical_axis,
share=True,
)
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
# Run the surface3d.py example, adding
ax.roll = 45
# It shows the plot, in the intended funny orientation (roll=45)
# Then move the mouse - you will see the orientation jump suddenly (to roll=0)
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
and azim
(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