Skip to content
Advertisement

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 does not for 3d:

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

Is there a different syntax for the 3d case, or it’s not implemented?

Advertisement

Answer

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).

Advertisement