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

Standardize edge-on axis locations when viewing primary 3d axis planes by scottshambaugh · Pull Request #23644 · matplotlib/matplotlib · GitHub

Repository navigation

Standardize edge-on axis locations when viewing primary 3d axis planes - #23644

Merged
QuLogic merged 5 commits into
matplotlib:mainfrom
scottshambaugh:3d_view_axes_alignmnet
Aug 19, 2022
Merged

QuLogic merged 5 commits into
matplotlib:mainfrom
scottshambaugh:3d_view_axes_alignmnet

Conversation

scottshambaugh commented Aug 17, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor

PR Summary

For the special cases of looking at the 3d axes in the 6 primary view planes (defined in the docs in #23600), draw the axes such that one is on the bottom edge and the other intersects at the low value (ie the intersection is at the origin for these examples). This blends smoothly when rotating the axes manually, since we are only looking at the epsilon case.

Code to generate these plots is the same as here.

Before:

After:

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

  • [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).
  • [N/A] Documentation is sphinx and numpydoc compliant (the docs should build without error).

scottshambaugh force-pushed the 3d_view_axes_alignmnet branch from ca1af31 to 7e5c070 Compare August 17, 2022 05:15
scottshambaugh changed the title Put edge-on axes on left and right when viewing 3d axis planes Put edge-on axes on left and bottom when viewing 3d axis planes Aug 17, 2022
scottshambaugh changed the title Put edge-on axes on left and bottom when viewing 3d axis planes Put edge-on axes on left and bottom when viewing primary 3d axis planes Aug 17, 2022
scottshambaugh marked this pull request as ready for review August 17, 2022 05:17
scottshambaugh force-pushed the 3d_view_axes_alignmnet branch 2 times, most recently from e34be8a to 7fc0b7d Compare August 17, 2022 05:32

QuLogic commented Aug 17, 2022

Copy link
Copy Markdown
Member

Would it make sense for the negative planes to swap left/right edges? So that the lines always go through 0.0?

scottshambaugh commented Aug 17, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

I had thought about that and thought it might be less useful when the axes are shifted away from 0, but am open to that too. Either is an improvement over the current.

scottshambaugh marked this pull request as draft August 17, 2022 18:20
scottshambaugh changed the title Put edge-on axes on left and bottom when viewing primary 3d axis planes Standardize edge-on axis locations when viewing primary 3d axis planes Aug 17, 2022
scottshambaugh force-pushed the 3d_view_axes_alignmnet branch from 7fc0b7d to 14bd014 Compare August 18, 2022 00:17

scottshambaugh commented Aug 18, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

@QuLogic trying it out, I like the layout of your suggestion just as much and it probably makes more intuitive sense. Simplifies the logic too. I replaced the image in the top post so you can look at it

scottshambaugh commented Aug 18, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Just for fun, here's an "unfolded" view of a 3D plot that might be useful to people/worth sticking in docs.

import matplotlib.pyplot as plt

def annotate_axes(ax, text, fontsize=18):
    ax.text(x=0.5, y=0.5, z=0.5, s=text,
            va="center", ha="center", fontsize=fontsize, color="black")

# (view, (elev, azim, roll))
views = [( 'XY', ( 90, -90, 0)), 
         ( 'XZ', (  0, -90, 0)),  
         ( 'YZ', (  0,   0, 0)), 
         ('-XY', (-90,  90, 0)), 
         ('-XZ', (  0,  90, 0)),
         ('-YZ', (  0, 180, 0))]

layout = [['XY', '.',  'L',  '.'],
          ['XZ','YZ','-XZ','-YZ',],
          ['.',  '.','-XY',  '.',]]
fig, axd = plt.subplot_mosaic(layout, subplot_kw={'projection': '3d'})
for i in range(len(axd) - 1):
    plane = views[i][0]
    axd[plane].set_xlabel('x')
    axd[plane].set_ylabel('y')
    axd[plane].set_zlabel('z')
    axd[plane].set_proj_type('ortho')
    axd[plane].view_init(elev=views[i][1][0], azim=views[i][1][1], roll=views[i][1][2])

    label = f'{plane}\n{views[i][1]}'
    annotate_axes(axd[plane], label, fontsize=14)

label = 'matplotlib Axes3D Primary View Planes\nax.view_init(elev, azim, roll)'
annotate_axes(axd['L'], label, fontsize=18)
axd['L'].set_axis_off()
plt.tight_layout()

QuLogic commented Aug 18, 2022 •
edited
Loading

Copy link
Copy Markdown
Member

OK, sorry one more question; can the third Axis also always appear around 0/0?

scottshambaugh commented Aug 18, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Unfortunately not, to do so would require having the backing planes in the +-XY and +-YZ views blocking either the plot volume or the axis spines. Here are the plots with the same axis locations rotated slightly off-angle to help visualize this.

I mean, I supposed you could carve out blocking views for specifically these angles, but then it's a discontinuous flash when rotating the plots manually or programmatically. And I think it'd be pretty ugly to implement.

Comment thread lib/mpl_toolkits/tests/test_mplot3d.py Outdated
Comment thread lib/mpl_toolkits/tests/test_mplot3d.py Outdated
Comment thread lib/mpl_toolkits/mplot3d/axis3d.py Outdated
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Comment thread lib/mpl_toolkits/mplot3d/axis3d.py Outdated
QuLogic merged commit 2e8231f into matplotlib:main Aug 19, 2022
QuLogic added this to the v3.6.0 milestone Aug 19, 2022
scottshambaugh mentioned this pull request Aug 24, 2022
2 tasks done
QuLogic mentioned this pull request Sep 9, 2022
2 tasks done
imgbot Bot pushed a commit to kkipngenokoech/matplotlib that referenced this pull request Apr 19, 2026
matplotlib#23644)

* Put edge-on axes on left and right when viewing 3d axis planes

Tests

Fix broken tests

Clean up test

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
imgbot Bot pushed a commit to kkipngenokoech/matplotlib that referenced this pull request Apr 19, 2026
matplotlib#23644)

* Put edge-on axes on left and right when viewing 3d axis planes

Tests

Fix broken tests

Clean up test

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL