-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Standardize edge-on axis locations when viewing primary 3d axis planes #23644
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
Standardize edge-on axis locations when viewing primary 3d axis planes #23644
Conversation
ca1af31
to
7e5c070
Compare
e34be8a
to
7fc0b7d
Compare
Would it make sense for the negative planes to swap left/right edges? So that the lines always go through 0.0? |
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. |
Tests Fix broken tests Clean up test
7fc0b7d
to
14bd014
Compare
@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 |
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() |
OK, sorry one more question; can the third Axis also always appear around 0/0? |
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. |
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
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
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).