-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
add third angle to view_init() #14453
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
my searching of how this could work ends here. I would kindly ask the community to implement this third angle to complete the 3D plotting in this case. |
Implementing this would likely require recoding a few things that relied on
implicit assumptions baked into mplot3d such as the code that figures out
where to draw the axes labels so that it is always the exterior boundary
and connected to the others (which also controls the placement of offsets),
and the 2D -> 3D estimate calculation (used for the cursor display). There
are probably a few others, but they aren't coming to mind right now. Not
saying it is impossible, but it would be a bit of an undertaking.
Another aspect of this that would need to be addressed is that mplot3d's
interactivity is currently designed around two degrees of freedom, which
are handled by dragging the mouse in the X and Y directions. Another action
would be needed to introduce control for this proposed third degree of
freedom.
…On Wed, Mar 10, 2021 at 2:48 AM SReich-EMI ***@***.***> wrote:
my searching of how this could work ends here. I would kindly ask the
community to implement this third angle to complete the 3D plotting in this
case.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#14453 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACHF6AG5WIZZQJTKTVVWGLTC4P5TANCNFSM4HTTQWOA>
.
|
This is something I've been frustrated with pretty much every single time I need to plot something in 3D, and I'm going to take a stab at it this weekend and see how far I can get. The missing piece is that azimuth, elevation, and radius uniquely define a viewpoint in 3D space, but you need an additional angle defining the rotation about the radius vector in order to fully capture the entire space of view orientations. If we add this 3rd angle with a default value of 0 deg, it should not break any old code. As to naming this additional angle, I think roll is the obvious choice. It aligns with both the aerospace pith/yaw/roll convention, as well as the camera angle pan/tilt/roll convention. On the other hand I have seen tilt, twist, lean, and bank used for this angle, so if someone has a strong opinion or a source for the canonical term used in computer graphics I'm open to that. We will be jumping ahead of matlab features a bit, so if they decide to add this in the future and choose a different name there is the risk of divergence. Really this should be done using quaternions - Euler angles are pretty much always bad. But since quaternions aren't natively in numpy we probably don't want to introduce those as a dependency just to avoid gimbal lock at the two poles. |
This looks like a relevant PR to keep in mind when reworking this: #10762 |
There are two aspects to consider:
|
Finished my PR, it's ready for review. |
This is brilliant, thank you so much @scottshambaugh ! |
I updated my answer in the SO thread: https://stackoverflow.com/a/56457693/7042795 |
Thanks a lot for your work! I will surely test it in the next days! |
Bug report
Bug summary
mpl_toolkits.mplot3d.axes3d.Axes3D.view_init
provides a means to set the elevation and the azimuth, but the z-axis is always aligned with the vertical camera axis.
A third angle would be required to permit any view.
The issue was reported on stackoverflow 3.5 years ago.
Code for reproduction
Actual outcome
Now, however hard you try to rotate the plot interactively or what angles you set in
ax.view_init()
, you will never be able to get the z-axis in a horizontalish position that is required to produce the plot below:Expected outcome
By rotating interactively or via

ax.view_init()
one should be able to obtain this view below. Unfortunately, this is not possible.Matplotlib version
The text was updated successfully, but these errors were encountered: