python - 是否可以使 matplotlib 图形轴等比例缩放?

标签 python matplotlib

我正在尝试在 matplotlib 中制作一个图表,包含 5-5120 之间的值,但是它没有平均缩放,而是像它应该的那样制作一条漂亮的曲线,它不均匀地缩放 x 轴,使其看起来是线性的。

EggSUM

使用多轴缩放工具,无济于事。尝试更改轴时,出现此错误 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/

相关文章:

带可选组的 p​​ython 正则表达式

python - 在 python3 中检测到输入之前如何执行某些操作?

python - 变形金刚 BartTokenizer::add_tokens() 不能像我期望的那样工作后缀

python - 使用 Python 中的 Count-in-Cells 在 3D 星场中进行聚类

python - 使用 matplotlib 的 3D 曲面图,使用数据框列输入数据

python - 带有矢量文本的 matplotlib 位图图

python - 查找未被字母字符包围的单词

javascript - Python:如何使用 python 单击网页中的按钮?

python - 在 seaborn 热图中分隔组的线

python - 防止 matplotlib 有状态