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

Correct roll angle units, issue #28256 #28261

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

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,7 @@ def _on_move(self, event):
dazim = -(dy/h)*180*np.sin(roll) - (dx/w)*180*np.cos(roll)
elev = self.elev + delev
azim = self.azim + dazim
roll = self.roll
vertical_axis = self._axis_names[self._vertical_axis]
self.view_init(
elev=elev,
Expand Down
25 changes: 25 additions & 0 deletions 25 lib/mpl_toolkits/mplot3d/tests/test_axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,31 @@ def test_shared_axes_retick():
assert ax2.get_zlim() == (-0.5, 2.5)


def test_rotate():
"""Test rotating using the left mouse button."""
for roll in [0, 30]:
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
ax.view_init(0, 0, roll)
ax.figure.canvas.draw()

# drag mouse horizontally to change azimuth
dx = 0.1
dy = 0.2
ax._button_press(
mock_event(ax, button=MouseButton.LEFT, xdata=0, ydata=0))
ax._on_move(
mock_event(ax, button=MouseButton.LEFT,
xdata=dx*ax._pseudo_w, ydata=dy*ax._pseudo_h))
ax.figure.canvas.draw()
roll_radians = np.deg2rad(ax.roll)
cs = np.cos(roll_radians)
sn = np.sin(roll_radians)
assert ax.elev == (-dy*180*cs + dx*180*sn)
assert ax.azim == (-dy*180*sn - dx*180*cs)
assert ax.roll == roll


def test_pan():
"""Test mouse panning using the middle mouse button."""

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.