Skip to content

3d plot view angle documentation #23721

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 2 commits into from
Aug 26, 2022

Conversation

scottshambaugh
Copy link
Contributor

@scottshambaugh scottshambaugh commented Aug 24, 2022

PR Summary

Adds documentation and images for the 3d plot view angle conventions. Also adds an example showing the primary view planes. Closes #21508

Inkscape file to generate the view angles plot is attached (the arrows render weird in the svg preview here for some reason).
mplot3d_view_axes

PR Checklist

Tests and Styling

  • [N/A] Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • [N/A] New features are documented, with examples if plot related.
  • [N/A] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@scottshambaugh scottshambaugh force-pushed the 3d_axes_view_docs branch 2 times, most recently from 9a27673 to 16a5e9c Compare August 24, 2022 04:47
@scottshambaugh scottshambaugh marked this pull request as ready for review August 24, 2022 04:50
@scottshambaugh
Copy link
Contributor Author

scottshambaugh commented Aug 24, 2022

@oscargus
Copy link
Member

I think that it is possible to store an svg-file and use that? (There's been a similar case in SymPy reducing the file size from MBs to kb... I do not know if any specific settings are required. But most browsers can render svg anyway?)

But the image looks good!

@timhoffm
Copy link
Member

timhoffm commented Aug 24, 2022

PNG size can be reduced by factors if put through a compressor like https://tinypng.com/. I think if applied to both images, sizes are reasonable small. The real advantage of SVG would be that we could adapt it later on, but I'm ok with PNG if that's what you can generate.

Content:

  1. The view direction line changes from green to black, which looks weird to me:
    grafik

  2. I find the view plane a bit hard to understand, though after thinking about it, I believe it's correct.
    Would it be helpful to add the camera position and view cone similar to
    grafik
    (don't need the fancy camera picture necessarily :))

@scottshambaugh scottshambaugh force-pushed the 3d_axes_view_docs branch 2 times, most recently from 0a26d27 to 62d7ce7 Compare August 24, 2022 13:26
@scottshambaugh
Copy link
Contributor Author

scottshambaugh commented Aug 24, 2022

PNGs are smaller, thanks for the site. The issue with svg is that different browsers render differently, and we actually have a great example right here. In the screenshot of the svg image for @timhoffm it looks like the arrows are not present for some reason, whereas I see arrows colored black in the previews, and when I open in inkscape the arrows colored the same as their lines (what I intended and what the png shows). Tim, do the arrows there resolve the overlaying lines looking weird?
image
image

Updated to add a little camera cone, I think I like it better even if it makes the plot a bit busier.

@story645
Copy link
Member

Wondering if for this PR or a follow on, the section in the 3D FAQ can be added/consolidated into the doc?

@scottshambaugh
Copy link
Contributor Author

Are you asking for the view angles to be added to the FAQ, or the FAQ info to be interspersed elsewhere where it makes sense?

@story645
Copy link
Member

story645 commented Aug 24, 2022

If the relevant parts of the FAQ can be incorporated into the new document so that information isn't spread across two.

@scottshambaugh
Copy link
Contributor Author

I don't see anything in the FAQ that I think it makes sense to pull out to the new page, but I'm happy to just put all the new info into the existing FAQ.

@story645
Copy link
Member

story645 commented Aug 24, 2022

Then just forget my suggestion, (sorry) since I like this is a standalone & think it's more discoverable that way (I'm not a big fan of FAQs)

@scottshambaugh
Copy link
Contributor Author

Decided to test the claim that you could print out and fold the primary planes image into a box:

0B376F7A-503B-4BB0-B373-B731B3837453

@timhoffm
Copy link
Member

timhoffm commented Aug 25, 2022

The camera looks good and the arrow also resolves my line issue 👍.

One additional idea for decluttering: How about only indicating the roll direction:

image

Technically, that's a bit different than the azimuth/elevation arrows, which show magnitude, but I think people still understand what roll is.

Maybe even show the viewing plane for roll=0, which again may be easier to comprehend as the user has less angles to process. The roll arrow then just indicates "this is the direction roll would apply to"

@oscargus
Copy link
Member

OK! I get the size and rendering issue, but wouldn't it make sense to have the "box" as svg so that it can easily be resized when printing? (Given that the size is not completely off. Or generate that image on the fly? I assume it is generate with mpl?)

@scottshambaugh scottshambaugh force-pushed the 3d_axes_view_docs branch 2 times, most recently from 9e92ed9 to 573f93a Compare August 26, 2022 03:30
@scottshambaugh
Copy link
Contributor Author

Ok, addressed those comments. I didn't totally go with Tim's suggestion since I think showing the roll angle zero reference is important, but I did take out two of the other lines there that weren't adding much. And to Oscar's suggestion, I made the unfolded box plot a gallery example with the generating code right there. I think it all looks good!

Built docs API page: https://output.circle-artifacts.com/output/job/0162ce41-cee3-47e2-a5a8-61aa17145914/artifacts/0/doc/build/html/api/toolkits/mplot3d/view_angles.html
Built docs gallery example: https://output.circle-artifacts.com/output/job/0162ce41-cee3-47e2-a5a8-61aa17145914/artifacts/0/doc/build/html/gallery/mplot3d/view_planes_3d.html

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.

Looks great!

Optional: It may be neat to add the fold lines to the unfolded view. But we can always add that later. I'd like to get this into 3.6 docs. So we should merge soon.

axd[plane].view_init(elev=views[i][1][0],
azim=views[i][1][1],
roll=views[i][1][2])
axd[plane].set_box_aspect(None, zoom=1.25)
Copy link
Member

Choose a reason for hiding this comment

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

Would this be a good use for axs[plane].axis('equal')? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A cutout should work for any aspect box :). But right now that command would only change the data limits! Need #23552 to merge in to change the box.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, let's to this later then. Since we've already released 3.6 RC1, #23552 can't go into 3.6 anymore.

@timhoffm timhoffm added this to the v3.6.0 milestone Aug 26, 2022
@timhoffm timhoffm merged commit a663f7e into matplotlib:main Aug 26, 2022
@timhoffm
Copy link
Member

@scottshambaugh thanks!

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Aug 26, 2022
timhoffm added a commit that referenced this pull request Aug 26, 2022
…721-on-v3.6.x

Backport PR #23721 on branch v3.6.x (3d plot view angle documentation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Doc]: Create diagram to show rotation directions for 3D plots
4 participants