-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
[Bug]: class Axes3D.set_box_aspect() sets wrong aspect ratios when Axes3D.view_init( vertical_axis='y') is enabled. #24328
Comments
Thanks! I do not recall that |
Yeah I'd love to! This would be my first time commit a PR so I still have to read the guidelines and figure out what to do here on github. Thank you |
Sounds great! I was wrong about the history of the methods, but it seems like the vertical_axis is stored as matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py Line 417 in 0b6d370
|
Thank you, I was browsing through the files today and found that line of code but couldn't figure out the structure of the vertical axis. My solution so far is not very elegant but does the trick: Before setting
|
I think I found the problem:
In order to solve the problem just adding after calling roll to vertical would work. |
Hi @Michallote, are you still interested in making a PR for this? We have a guide on opening a PR for new contributors at https://matplotlib.org/stable/devel/contributing.html#contributing-code, and feel free to hop on the gitter chat if you have more questions! |
I made an attempt in #28041. The idea is if the x-axis has the smallest aspect it should always be the smallest regardless of what vertical_axis says. |
Bug summary
Whenever creating a 3D plot with
vertical_axis = 'y'
option theset_box_aspect()
method scales the axes incorrectly. The 3-tuple is expected to behave asx:y:z
, instead it behaves likez:x:y
Code for reproduction
Actual outcome
The box_aspect tuple:
box_aspect = (4,2,4)
#(x,y,z)Actually the axis scaled as
box_aspect = (4,2,4)
-> #(z,x,y)Like if shifting y to the right.
Expected outcome
To produce this result i just applied the same logic in reverse:
box_aspect = (4,4,2)
#(z,x,y) <- Expecting the outcome to be applied like thisAnd it actually does.
Additional information
This only happens as explained in the title when both
vertical = y
option is enabled and we try to manually scale_box_aspect(). The problem is probably from how was vertical axis selection actually implemented.From the documentation:
This behaviour is not respected when
vertical_axis = 'y'
in enabled. The behaviour appears to be:z:x:y
instead.To actually fix this I just created a tuple with the new definition in mind, this could just be patched by shifting the tuple to make the vertical axis be the last element of the tuple
(x,y,z) -> input tuple
vertical axis == 'z' -> (x,y,z) no problem
vertical axis == 'y' -> (z,x,y) rotate right the tuple
vertical axis == 'x' -> (y,z,x) rotate right twice the tuple
Operating system
Windows
Matplotlib Version
'3.6.1'
Matplotlib Backend
Qt5Agg
Python version
Python 3.8.5
Jupyter version
Spyder 4.1.5
Installation
conda
The text was updated successfully, but these errors were encountered: