pythonmatplotlibmatplotlib-3d

set matplotlib 3d plot aspect ratio


import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

Setting the aspect ratio works for 2d plots:

ax = plt.axes()
ax.plot([0,1], [0,10])
ax.set_aspect('equal', 'box')

But it does not work for 3d:

ax = plt.axes(projection='3d')
ax.plot([0,1], [0,1], [0,10])
ax.set_aspect('equal', 'box')

How do I set the aspect ratio for 3d?


Solution

  • My understanding is basically that this isn't implemented yet (see this bug in GitHub). I'm also hoping that it is implemented soon. See This link for a possible solution (I haven't tested it myself).