In the example below, I wish to observe a unitary 3D cube in its diagonal axis (1, 1, 1).
azimut and elevation angle should be both 45°, normally.
Why do I need to set elevation = 28° ????
Thanks,
Patrick
Traceback (most recent call last):
Input In [18] in <module>
ax[1].axis('equal')
File /local/data1/miniconda3/lib/python3.8/site-packages/matplotlib/axes/_base.py:2047 in axis
self.set_aspect('equal', adjustable='datalim')
File /local/data1/miniconda3/lib/python3.8/site-packages/mpl_toolkits/mplot3d/axes3d.py:311 in set_aspect
raise NotImplementedError(
NotImplementedError: Axes3D currently only supports the aspect argument 'auto'. You passed in 'equal'.
So, basically, there is a different scaling for the z-axis compared to the x- and y-axes. You can see that from the grid blocks being rectangles (rather than squares, as for the bottom surface).
You can get a bit closer by using: ax[1].set_box_aspect((4, 4, 4)), but it is still not exact. (Of course, you can probably find a better value for the last number, but that is about as bad as 28 degrees...) Now it at least looks like a cube.
Hi @oscargus,
Thanks for your reply.
using ax[1].set_box_aspect((1, 1, 1)), the elevation angle is now 35°.
That is the correct elevation angle (atan(1/sqrt(2) ~35°) and not 45° as I have previously written.
Thanks.
Activity
oscargus commented on Feb 28, 2022
Ideally, it should be possible to do ax[1].axis('equal') to obtain what you are looking for (see https://matplotlib.org/stable/gallery/subplots_axes_and_figures/axis_equal_demo.html). However, Axes3D does not (yet) support that:
Traceback (most recent call last): Input In [18] in <module> ax[1].axis('equal') File /local/data1/miniconda3/lib/python3.8/site-packages/matplotlib/axes/_base.py:2047 in axis self.set_aspect('equal', adjustable='datalim') File /local/data1/miniconda3/lib/python3.8/site-packages/mpl_toolkits/mplot3d/axes3d.py:311 in set_aspect raise NotImplementedError( NotImplementedError: Axes3D currently only supports the aspect argument 'auto'. You passed in 'equal'.So, basically, there is a different scaling for the z-axis compared to the x- and y-axes. You can see that from the grid blocks being rectangles (rather than squares, as for the bottom surface).
oscargus commented on Feb 28, 2022
You can get a bit closer by using: ax[1].set_box_aspect((4, 4, 4)), but it is still not exact. (Of course, you can probably find a better value for the last number, but that is about as bad as 28 degrees...) Now it at least looks like a cube.
patquem commented on Feb 28, 2022
Hi @oscargus,
Thanks for your reply.
using ax[1].set_box_aspect((1, 1, 1)), the elevation angle is now 35°.
That is the correct elevation angle (atan(1/sqrt(2) ~35°) and not 45° as I have previously written.
Thanks.
jondo commented on Aug 2, 2022
B.t.w., this is a successor of #1077.