matplotlib x y limit and aspect ratio

matplotlib x y limit and aspect ratio

Use

plt.xlim(-1,1)
plt.gca().set_aspect('equal', adjustable='box')

if

plt.xlim(-1,1)
plt.axes().set_aspect('equal', 'datalim')

doesn’t work.

Planted: by ;

L Ma (2016). 'matplotlib x y limit and aspect ratio', Datumorphism, 07 April. Available at: https://datumorphism.leima.is/til/programming/matplotlib-x-y-limit-and-aspect-ratio/.