I can't seem to find documentation regarding the ability to scale axes in a 3d image using matplotlib.
For example, I have the image:
And the axes have different scales. I would like them to be uniform.
I can't seem to find documentation regarding the ability to scale axes in a 3d image using matplotlib.
For example, I have the image:
And the axes have different scales. I would like them to be uniform.
Usually it is easiest for you to include some of the code that generated the image, so we can see what you've tried and also the general setup of your code. That being said, the inclusion of the following should work:
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot as plt
fig = plt.figure()
ax = Axes3D(fig)
ax.set_xlim3d(0, 1000)
ax.set_ylim3d(0, 1000)
ax.set_zlim3d(0, 1000)
Tested in python 3.11.2
, matplotlib 3.7.1
fig = plt.figure(figsize=(10, 5))
ax = fig.add_subplot(111, projection='3d')
ax.set_xlim3d(0, 1000)
ax.set_ylim3d(0, 1000)
ax.set_zlim3d(0, 1000)
The following sets the box aspect ratio from the current axes limits to achieve the "equal" behavior [source]:
ax.set_box_aspect([ub - lb for lb, ub in (getattr(ax, f'get_{a}lim')() for a in 'xyz')])
© 2022 - 2024 — McMap. All rights reserved.