python - 如何在 matplotlib.pyplot 中关闭自动缩放

标签 python matplotlib

我在 python 中使用 matplotlib.pyplot 来绘制我的数据。问题是它生成的图像似乎是自动缩放的。我怎样才能关闭它,以便当我在 (0,0) 处绘制某些东西时,它会固定在中心?

最佳答案

你想要 autoscale功能:

from matplotlib import pyplot as plt

# Set the limits of the plot
plt.xlim(-1, 1)
plt.ylim(-1, 1)

# Don't mess with the limits!
plt.autoscale(False)

# Plot anything you want
plt.plot([0, 1])

关于python - 如何在 matplotlib.pyplot 中关闭自动缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38629830/

相关文章:

python - 错误: [Errno 32] Broken pipe in python code

python - 使用 Matplotlib 平滑等值线图中的数据

python - 如何确定黑盒是多项式还是指数

Python:如何在函数中分别绘制不同的图?

python - 线条颜色取决于趋势

python - 在 Python 中评估极坐标网格上的插值函数的最快方法是什么?

python - WCF 和 Python SUDS 之间用于继承的 XML 差异?

python - Jinja 过滤器无效,过滤器是内置的

python - 外部 API RabbitMQ 和 Celery 速率限制

python - 从一个 python 文件调用多个绘图函数时出现问题