-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[ENH]: Add ability to snap view to primary axis planes in 3D plots #23544
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
Comments
Here are the view angles I would propose. This matches matlab's conventions and keeps the roll angle at 0. The inverse views show the other 3 sides of the box, and are defined by a 180 deg rotation about the local vertical axis. Might be worth a PR at some point to make all the axes in these orientations show along the bottom and left edges. (Edit: see #23644) import matplotlib.pyplot as plt
# (view, (elev, azim, roll))
views = [( 'XY', (90, -90, 0)),
( 'XZ', (0, -90, 0)),
( 'YZ', (0, 0, 0)),
('-XY', (-90, 90, 0)),
('-XZ', (0, 90, 0)),
('-YZ', (0, 180, 0)),
]
fig, axs = plt.subplots(2, 3, subplot_kw={'projection': '3d'})
for i, ax in enumerate([ax for ax_row in axs for ax in ax_row]):
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_title(views[i][0])
ax.set_proj_type('ortho')
ax.view_init(elev=views[i][1][0], azim=views[i][1][1], roll=views[i][1][2]) |
This requires adding a right-click menu in a backend independent way? I think that will be a huge benefit in general as well, being a right-click person... |
Yeah, I see the scope of this as twofold.
|
Problem
In matlab, you can right-click on a 3D plot and a context menu pops up that gives you the option to 'Go to X-Y view', 'Go to X-Z view', and 'Go to Y-Z view'. The view then snaps to viewing that plane face-on. Something similar would be very useful in matplotlib.
Proposed solution
Either a right-click menu or a toolbar dropdown with similar snapping options. That would then set the appropriate
ax.view_init(elev, azim, roll)
elevation and azimuth view angles.The text was updated successfully, but these errors were encountered: