如何在 matplotlib.pyplot 中关闭自动缩放 [英] How to turn off autoscaling in matplotlib.pyplot

查看:167
本文介绍了如何在 matplotlib.pyplot 中关闭自动缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在python中使用matplotlib.pyplot绘制数据.问题是它生成的图像似乎是自动缩放的.如何关闭此功能,以便当我在(0,0)处绘制内容时将其固定放置在中心位置?

I am using matplotlib.pyplot in python to plot my data. The problem is the image it generates seems to be autoscaled. How can I turn this off so that when I plot something at (0,0) it will be placed fixed in the center?

推荐答案

您想要 autoscale 功能:

You want the autoscale function:

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])

这篇关于如何在 matplotlib.pyplot 中关闭自动缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆