我正在尝试在 matplotlib 中制作一个图表,包含 5-5120 之间的值,但是它没有平均缩放,而是像它应该的那样制作一条漂亮的曲线,它不均匀地缩放 x 轴,使其看起来是线性的。
使用多轴缩放工具,无济于事。尝试更改轴时,出现此错误 MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.在未来的版本中,将始终创建并返回一个新实例。同时,通过将唯一标签传递给每个轴实例,可以抑制此警告,并确保 future 的行为。
# plotting the points
plt.plot(n, m)
# naming the x axis
plt.xlabel('X')
# naming the y axis
plt.ylabel('Y')
# giving a title to my graph
plt.title('test')
plt.axes().set_aspect(aspect=1)
# function to show the plot
plt.show()```
最佳答案
你应该尝试使用:
plt.gca().set_aspect('equal', adjustable='box')
或
plt.axis('equal')
或
plt.axis('scaled')
关于python - 是否可以使 matplotlib 图形轴等比例缩放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57719517/