FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add third angle to view_init() · Issue #14453 · matplotlib/matplotlib · GitHub

Repository navigation

add third angle to view_init() #14453

Closed

Description

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

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = Axes3D(fig)

ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()

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

  • Operating system: Ubuntu 16.04
  • Matplotlib version: 3.1.0, py37h5429711_0
  • Matplotlib backend: Qt5Agg
  • Python version: 3.7.3 (conda)

Activity

  1. SReich-EMI commented on Mar 10, 2021

    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.

  2. WeatherGod commented on Mar 10, 2021

    Member
  3. scottshambaugh commented on Oct 21, 2021

    Contributor

    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.

  4. scottshambaugh commented on Oct 21, 2021

    Contributor

    This looks like a relevant PR to keep in mind when reworking this: #10762

  5. timhoffm commented on Oct 21, 2021

    Member

    There are two aspects to consider:

    • With the restricted two angles, the final view direction does not depend on the execution order of the two rotations.
      With three angles, you have to find a reasonable execution order and document that.
    • When interactively navigating in the view window we currently map the two screeen directions horizontal/vertical to azimuth/elevation. AFAICS there is no simple way of controlling the third dimension interactively (though one might look at 3d programs how they solve this)
  6. scottshambaugh commented on Oct 22, 2021

    Contributor

    Finished my PR, it's ready for review.

  7. baloe commented on Dec 3, 2021

    Author

    This is brilliant, thank you so much @scottshambaugh !

  8. baloe commented on Dec 3, 2021

    Author

    I updated my answer in the SO thread: https://stackoverflow.com/a/56457693/7042795

  9. added this to the v3.6.0 milestone on Dec 3, 2021
  10. SReich-EMI commented on Dec 6, 2021

    Thanks a lot for your work! I will surely test it in the next days!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL