Questions and discussion for this lecture live here. Fire away by hitting Reply below
Hello,
At about 7:55 you mentioned that you would expect to get a square in divisions when you look at elevation and rotation to 0. There is a variable called box_aspect that is a tulle with a default value of (4,4,3). This value can be change by adding box_aspect=(4,4,4) after projection=‘3d’ in fig.add_axes().
Or it can be set in another line of code using axes.set_box_aspect(4,4,4).
Also, to get an orthogonal view (instead of perspective), pass proj_type=‘ortho’ in fig.add_axes()
Fantastic thanks @Tom1961. Great contribution.
I have to assume that these (at least proj_type
) are more recent additions to matplotlib because I did a lot of head scratching when writing this code to try and fix the scale issue - so fairly sure such a simple solution wasn’t available…less sure I didn’t just miss box_aspect
.
In any event - thanks again for the contribution!
Seán
Update as of matplotlib 3.6.0
Just wanted to add a small update here, as of matplotlib 3.6.0, set_aspect('equal')
now works for 3D plots. So, in addition to the suggestions above, to obtain correct 3D scaling for a 3D plot, simply call:
axes.set_aspect('equal') #As of matplotlib 3.6.0
…assuming axes
is the handle to your axis.
Seán