在matplotlib中设置轴 [英] Setting an axis in matplotlib

查看:90
本文介绍了在matplotlib中设置轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在matplotlib中生成一个图,我想将x轴设置在0-10000之间,但是我不想更改y轴,我希望该图自行完成.现在,两个轴都将自动生成.

I'm producing a graph in matplotlib and I would like to set the x-axis between 0-10000 but I do not want to change the y axis I want the graph to do that on it's own. Right now both axis are automatically generated.

这是一个例子:

import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,4,9,16], 'ro')
plt.axis([0, 6, 0, 20]) 

axis命令无法帮助我,因为我也必须设置y值.同样由于某种原因,xlim无法正常工作,这是因为它没有xlim参数.

The axis command cannot help me because I would have to set the y value as well. Also for some reason xlim doesn't work it say's it has no argument xlim.

任何建议表示感谢

推荐答案

这对我来说似乎很好:

import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,4,9,16], 'ro')
# print plt.xlim()
plt.xlim(0, 10000)
# or 
# plt.xlim(xmin=0, xmax=10000)

这篇关于在matplotlib中设置轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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