Python Matplotlib';s set_方面似乎不起作用
我试图使用PyPlot可视化一组坐标,但我似乎没有像在MATLAB中习惯的那样得到“正方形”或“相等”轴。下面的脚本Python Matplotlib';s set_方面似乎不起作用,python,matplotlib,plot,Python,Matplotlib,Plot,我试图使用PyPlot可视化一组坐标,但我似乎没有像在MATLAB中习惯的那样得到“正方形”或“相等”轴。下面的脚本 import matplotlib.pyplot as plt coords = [ (20833.3333, 17100.0000), (20900.0000, 17066.6667), (21300.0000, 13016.6667), (21600.0000, 14150.0000),
import matplotlib.pyplot as plt
coords = [
(20833.3333, 17100.0000),
(20900.0000, 17066.6667),
(21300.0000, 13016.6667),
(21600.0000, 14150.0000),
(21600.0000, 14966.6667),
(21600.0000, 16500.0000),
(22183.3333, 13133.3333),
(22583.3333, 14300.0000),
(22683.3333, 12716.6667),
(23616.6667, 15866.6667),
(23700.0000, 15933.3333),
(23883.3333, 14533.3333),
(24166.6667, 13250.0000),
(25149.1667, 12365.8333),
(26133.3333, 14500.0000),
(26150.0000, 10550.0000),
(26283.3333, 12766.6667),
(26433.3333, 13433.3333),
(26550.0000, 13850.0000),
(26733.3333, 11683.3333),
(27026.1111, 13051.9444),
(27096.1111, 13415.8333),
(27153.6111, 13203.3333),
(27166.6667, 9833.3333),
(27233.3333, 10450.0000)
]
x, y = zip(*coords)
plt.plot(x, y, '.')
plt.show()
plt.axes().set_aspect('equal')
导致一个如下所示的绘图:
在我看来,间隔1000之间的间距在y轴上看起来更宽。为什么没有像我期望的那样工作
更新
实际上,在调用show()
之前必须设置axes()
。为了完整起见,以下是该图的外观:
在已查看绘图后,您正在更改坡向。这对我很有用:
import matplotlib.pyplot as plt
coords = [
(20833.3333, 17100.0000),
(20900.0000, 17066.6667),
(21300.0000, 13016.6667),
(21600.0000, 14150.0000),
(21600.0000, 14966.6667),
(21600.0000, 16500.0000),
(22183.3333, 13133.3333),
(22583.3333, 14300.0000),
(22683.3333, 12716.6667),
(23616.6667, 15866.6667),
(23700.0000, 15933.3333),
(23883.3333, 14533.3333),
(24166.6667, 13250.0000),
(25149.1667, 12365.8333),
(26133.3333, 14500.0000),
(26150.0000, 10550.0000),
(26283.3333, 12766.6667),
(26433.3333, 13433.3333),
(26550.0000, 13850.0000),
(26733.3333, 11683.3333),
(27026.1111, 13051.9444),
(27096.1111, 13415.8333),
(27153.6111, 13203.3333),
(27166.6667, 9833.3333),
(27233.3333, 10450.0000)
]
x, y = zip(*coords)
plt.plot(x, y, '.')
plt.axes().set_aspect('equal')
plt.show()
如果需要指定长方体的大小或纵横比,可以使用命令set_size_inches。我将用plt.gcf()替换plt.axes().set_aspect('equal')