Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add 3D plots to plot_types doc page #24108

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 1 commit into from
Oct 23, 2022

Conversation

j1642
Copy link
Contributor

@j1642 j1642 commented Oct 6, 2022

PR Summary

Add assorted 3D plot examples from the general gallery (https://matplotlib.org/devdocs/gallery/mplot3d/index.html) to the plot_types gallery (https://matplotlib.org/devdocs/plot_types/index.html) to increase visibility of Matplotlib's 3D capabilities.

Issue link: #23900

PR Checklist

Tests and Styling

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

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • 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).

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@story645
Copy link
Member

story645 commented Oct 6, 2022

Thanks for the PR! I unfortunately don't have concrete suggestions but I'm wondering if some of these examples can be smaller/more straightforward? The goal of this gallery isn't necessarily pretty pictures, just examples that clearly show what data goes into what plots & what plots are available.

@j1642 j1642 force-pushed the add-3d-plots-to-gallery branch 2 times, most recently from 034904d to 53ea816 Compare October 7, 2022 15:32
@j1642
Copy link
Contributor Author

j1642 commented Oct 7, 2022

Thanks for the feedback. I have curated a more straightforward set of examples in matplotlib/plot_types/3D.

Sorry about all of the commits, this is my first pull request and I'm still getting used to Git. If I need to rebase or do anything else, please let me know. I will wait for feedback before making any new commits or merges.

@story645
Copy link
Member

story645 commented Oct 7, 2022

It looks like your code got muddled in w/ the rebase.

Git is a pain. I'm gonna suggest cherry picking b/c it's what I just did to clean a branch, but there may be an easier way to clean your branch. Also feel free to drop by our incubator channel w/ questions!

  1. locally checkout main
    git checkout main
  2. rebase main to upstream main
    (on main) git rebase upstream/main
  3. checkout new branch FIX (while main is checked out, so FIX is branched off a synced main)
    (on main) git checkout -B FIX
  4. on new branch FIX, cherry pick just the commits that are relevant to this PR
    (on FIX) git cherry-pick 910ed53147058d02f43bd02865e7420be08e4969 53ea816a5e3e0a3002026c059f69aaf53c284e4b
  5. delete your local 'add-3d-plots-to-gallery'
    (on FIX) git branch --delete add-3d-plots-to-gallery
  6. rename FIX to 'add-3d-plots-to-gallery'
    (on FIX) git branch -m add-3d-plots-to-gallery
  7. check git log to check that the only commits on this branch are the ones relevant to this pr. Here's a simplified variant/the numbers may be different for you)
commit 910ed53147058d02f43bd02865e7420be08e4969 (HEAD ->'add-3d-plots-to-gallery, origin/'add-3d-plots-to-gallery)
3d example code

commit cada8fb565b1e1cfeb076f1f6ab791b1640d387d (upstream/main, main)
Merge: 363713442b da3790fc4e
  1. push back to this branch

@j1642 j1642 force-pushed the add-3d-plots-to-gallery branch from 3f66b2d to 52a1f12 Compare October 7, 2022 18:12
@timhoffm
Copy link
Member

timhoffm commented Oct 7, 2022

These examples need to become more in line with the rest of plot types (take the others as example):

  • Adapt the styling
  • Make the text minimal

@j1642 j1642 force-pushed the add-3d-plots-to-gallery branch from 52a1f12 to 5dfc6b1 Compare October 7, 2022 23:05
Copy link
Member

@story645 story645 left a comment

Choose a reason for hiding this comment

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

This is loads better! I'm a little concerned that the voxels example is still trying to do a drop too much.

The big things this needs is consistent figure creation and please follow the plot gallery style, which is that the examples have a title and then the next line is a link to the function being illustrated in that example
https://github.com/matplotlib/matplotlib/blob/main/plot_types/basic/scatter_plot.py

@j1642 j1642 force-pushed the add-3d-plots-to-gallery branch from 5dfc6b1 to 3296bd3 Compare October 13, 2022 00:58
@story645
Copy link
Member

Almost there! The gallery examples follow a # make data, # plot format which you've done in trisurf, voxels; please amend scatter, surface, and wireframe to match.

Also, the failed doc tests means I can't see how the new style is being applied to the gallery entries. I think sphinx is mad b/c you're using the same names as the gallery example:

WARNING: Duplicate example file name(s) found. Having duplicate file names will break some links. List of files: ['../plot_types/3D/scatter3d.py', '../plot_types/3D/surface3d.py', '../plot_types/3D/trisurf3d.py', '../plot_types/3D/voxels.py', '../plot_types/3D/wire3d.py']

so please change the names - appending simple should be fine.

@j1642 j1642 force-pushed the add-3d-plots-to-gallery branch from 3296bd3 to 3eeb45e Compare October 13, 2022 14:35
@j1642
Copy link
Contributor Author

j1642 commented Oct 13, 2022

Thanks again for feedback, everyone.

Where was that warning message about duplicated file names? I didn't see it under "Details" for "View the built docs" or "ci/circleci: docs-python38", but my browser was having issues showing the previous circleci.com page.

Edit: I see the warnings on circleci now.

@jklymak
Copy link
Member

jklymak commented Oct 13, 2022

This is looking good. You have a build failure however.

  1. Please remove the tick labels
  2. In the description, make it clear that these are from a toolkit. Something like "3D plots using 3D mpltoolkit". They are a bit confusing because they are not in the main library.

Thanks!

@j1642
Copy link
Contributor Author

j1642 commented Oct 13, 2022

One way to remove the tick labels is by adding ax.set_xticklabels([]), ax.set_yticklabels([]), and ax.set_zticklabels([]).

Is this acceptable? Or is there a cleaner, preferred way to remove all tick labels? Maybe through styling?

@story645
Copy link
Member

the examples all use ax.set to set stuff like ticks and you may need to edit the styles at https://github.com/matplotlib/matplotlib/tree/main/lib/matplotlib/mpl-data/stylelib to add in 3D configs

Copy link
Member

@story645 story645 left a comment

Choose a reason for hiding this comment

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

Yay, thanks for putting up w/ all the tweaks!

I think it's good enough to merge, but if you have bandwidth, I'd be interested in seeing some shades of blue color variation on the surfaces/wireframes and the voxels colored two colors.

@j1642 j1642 force-pushed the add-3d-plots-to-gallery branch from 5dfda69 to 458f6ab Compare October 19, 2022 21:09
@j1642
Copy link
Contributor Author

j1642 commented Oct 19, 2022

For the surfaces, I agree that a color gradient could increase visual clarity. I think these changes work well while adding minimal complexity.

Regarding the voxels, the color-related code was removed from the original gallery example. Is reintroducing distinct colors worth increasing the Plot Types code complexity?

For the wireframe, after reading through the docs and doing some testing, it is unclear if a z-coordinate-dependent color gradient can be added to each plotted line. And the cmap keyword, e.g. cmap=cm.viridis, does not change the wireframe appearance.

@story645
Copy link
Member

Yup you're right, wireframe doesn't support colormapping. Sorry about that! And I don't have strong opinions on voxels, so will agree w/ you to keep it on the simple less pretty side.

@story645
Copy link
Member

Oh this is so pretty and I'm just giving @jklymak and @timhoffm a day or two to comment before I merge.

Screenshot_20221019-225221.jpg

3D
--

3D plots using the mpl_toolkits library.
Copy link
Member

Choose a reason for hiding this comment

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

Tiny nit but can you crosslink this to the https://matplotlib.org/devdocs/api/toolkits/mplot3d.html API docs?

@j1642 j1642 force-pushed the add-3d-plots-to-gallery branch from 458f6ab to 7985c21 Compare October 20, 2022 14:16
@story645 story645 modified the milestones: v3.6-doc, v3.6.2 Oct 22, 2022
@story645 story645 merged commit f2e2f77 into matplotlib:main Oct 23, 2022
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Oct 23, 2022
@story645
Copy link
Member

Congrats 🥳 on your first PR into matplotlib, thank you so much for your patience with our feedback 😅, and we hope to see you again!

@story645 story645 linked an issue Oct 23, 2022 that may be closed by this pull request
5 tasks
oscargus added a commit that referenced this pull request Oct 23, 2022
…108-on-v3.6.x

Backport PR #24108 on branch v3.6.x (Add 3D plots to plot_types doc page)
@j1642 j1642 deleted the add-3d-plots-to-gallery branch November 14, 2022 18:51
@ksunden ksunden mentioned this pull request Feb 20, 2023
6 tasks
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]: Adding some 3D plots to plot gallery
5 participants