Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 357d3ba

Browse filesBrowse files
authored
Merge pull request #28294 from meeseeksmachine/auto-backport-of-pr-28261-on-v3.9.x
Backport PR #28261 on branch v3.9.x (Correct roll angle units, issue #28256)
2 parents 182238c + 042e1bb commit 357d3ba
Copy full SHA for 357d3ba

File tree

Expand file treeCollapse file tree

2 files changed

+26
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+26
-0
lines changed

‎lib/mpl_toolkits/mplot3d/axes3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/axes3d.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,7 @@ def _on_move(self, event):
15241524
dazim = -(dy/h)*180*np.sin(roll) - (dx/w)*180*np.cos(roll)
15251525
elev = self.elev + delev
15261526
azim = self.azim + dazim
1527+
roll = self.roll
15271528
vertical_axis = self._axis_names[self._vertical_axis]
15281529
self.view_init(
15291530
elev=elev,

‎lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/tests/test_axes3d.py
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,31 @@ def test_shared_axes_retick():
17661766
assert ax2.get_zlim() == (-0.5, 2.5)
17671767

17681768

1769+
def test_rotate():
1770+
"""Test rotating using the left mouse button."""
1771+
for roll in [0, 30]:
1772+
fig = plt.figure()
1773+
ax = fig.add_subplot(1, 1, 1, projection='3d')
1774+
ax.view_init(0, 0, roll)
1775+
ax.figure.canvas.draw()
1776+
1777+
# drag mouse horizontally to change azimuth
1778+
dx = 0.1
1779+
dy = 0.2
1780+
ax._button_press(
1781+
mock_event(ax, button=MouseButton.LEFT, xdata=0, ydata=0))
1782+
ax._on_move(
1783+
mock_event(ax, button=MouseButton.LEFT,
1784+
xdata=dx*ax._pseudo_w, ydata=dy*ax._pseudo_h))
1785+
ax.figure.canvas.draw()
1786+
roll_radians = np.deg2rad(ax.roll)
1787+
cs = np.cos(roll_radians)
1788+
sn = np.sin(roll_radians)
1789+
assert ax.elev == (-dy*180*cs + dx*180*sn)
1790+
assert ax.azim == (-dy*180*sn - dx*180*cs)
1791+
assert ax.roll == roll
1792+
1793+
17691794
def test_pan():
17701795
"""Test mouse panning using the middle mouse button."""
17711796

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.