Currently, we can get non-square axes in axes3D based on a simple hack from http://stackoverflow.com/a/10328142/2135095, by editing the `get_proj` function inside site-packages\mpl_toolkits\mplot3d\axes3d.py: def get_proj(self): relev, razim = np.pi * self.elev/180, np.pi * self.azim/180 try: self.localPbAspect = self.pbaspect except AttributeError: self.localPbAspect = [1,1,1] xmin, xmax = self.get_xlim3d() / self.localPbAspect[0] ymin, ymax = self.get_ylim3d() / self.localPbAspect[1] zmin, zmax = self.get_zlim3d() / self.localPbAspect[2] then in the code we can set the axes manually: fig = plt.figure() ax = fig.gca(projection='3d') ax.pbaspect = [1,1,0.5] it would be great if we can have some generic solution to achieve non-square axes.
Activity
baloe commentedon Jul 1, 2019
The hack above doesn't seem to work any more:
So I modified
get_projin the following way:This produces the desired output.
pmolodo commentedon Oct 22, 2024
For future searchers:
The way to set this now is via Axes3D.set_box_aspect([x, y, z])