Skip to content

Add documentation for Axes3d.view_init() angles #29114

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MischaMegens2
Copy link
Contributor

PR summary

This is an alternative for PR #28395, it adds documentation to clarify the relation between the Axes3d.view_init() angles and the rotation of the scene, and add recommendation to use keyword arguments; but unlike #28395, it leaves the original order (elev, azim, roll) unaffected. It closes Issue #28353.

PR checklist

- Clarify the relation between the view_init() angles and the rotation of the scene, and add recommendation to use keyword arguments

- Change axes.view_init() arguments to keywords if the arguments are numbers
- Label angles as elev, azim, or roll as appropriate, when it is not evident already
- Avoid unnecessary argument repetition (elev=elev, azim=azim, roll=roll)
- Stick with the original order: elev, azim, roll, in view_init() keyword arguments
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for rewriting!

A roll angle of 0, 90, 180, or 270 degrees will rotate these views
while keeping the axes horizontal or vertical.

The *azim*, *elev*, *roll* angles correspond to rotations of the scene
Copy link
Member

@timhoffm timhoffm Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A textual description is quite hard to follow. I suggest to instead link to https://matplotlib.org/devdocs/api/toolkits/mplot3d/view_angles.html#how-to-define-the-view-angle. And maybe move the quarternions there as well (in a note?).

vertical_axis=vertical_axis,
share=True,
)
self.view_init(elev, azim, roll, vertical_axis=vertical_axis,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I care too much, but why are we going back here to positional arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, with:
axes3d.py: line 142: self.view_init(self.initial_elev, self.initial_azim, self.initial_roll)
test_axes3d.py: line 180: ax.view_init(elev, azim, roll)
test_axes3d.py: line 1873: ax2.view_init(elev, azim, roll, share=True)
test_axes3d.py: line 1877: ax.view_init(elev, azim, roll)
rotate_axes3d_sgskip.py: line 47: ax.view_init(elev, azim, roll)
(And come to think of it, we could change axes3d.py, line 1372 too - consider it done.)

Since we are not going to change the order of the angles, there is no reason to use keyword arguments in these cases, it would just lead to duplication: elev=elev, azim=azim, roll=roll, for no benefit whatsoever, the intent is already clear without the keywords.

Unfortunately, this order does not match the order in which rotations are
applied, and it differs from the order used in other programs (``azim, elev``)
and in `matplotlib.colors.LightSource`. However, it cannot be
changed, since that would compromise backward compatibility.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this paragraph is needed, IMO it creates more confusion than it relieves.

with the original scene).

If you would like to make the connection with quaternions (because
`Euler angles are horrible
Copy link
Contributor

@scottshambaugh scottshambaugh Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an excellent reference, but I think the tone should be more neural. E.g. "See X for a discussion on why quaternions are a more natural way to represent orientations"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is being changed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is being changed.

What do you mean by this? I don’t see any changes here. Did you forget to push?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'm sorry, it is less than clear, I meant to say: I'm changing it and I'll push a commit once I've tried to address the other issues raised too. (It may take a little while.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MNT]: mplot3d azim-elev-roll order
3 participants