Would plt.axis('scaled')
be what you're after? That would produce a square plot, if the data limits are of equal difference.
If they are not, you could get a square plot by setting the aspect of the axes to the ratio of xlimits and ylimits.
import numpy as np
import matplotlib.pyplot as plt
fig, (ax1, ax2) = plt.subplots(1,2)
ax1.plot([-2.5, 2.5], [-4,13], "s-")
ax1.axis("scaled")
ax2.plot([-2.5, 2.5], [-4,13], "s-")
ax2.set_aspect(np.diff(ax2.get_xlim())/np.diff(ax2.get_ylim()))
plt.show()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…