如何在matplotlib中更改我的x轴范围 [英] How to change the range of my x-axis in matplotlib
本文介绍了如何在matplotlib中更改我的x轴范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试绘制一个包含 30.000 个值的列表.列表的名称是velocity_x".我只是用以下命令绘制它们:
I am trying to plot a list of 30.000 values. The name of the list is "velocity_x". I just plot them with the following command:
plot(velocity_x,'r')
结果如下图(不要注意虚线)
the result is shown in the image below (do not pay attention to the dashed line)
由于我使用的是该命令行,它会自动创建一个长度为 30.000 的 x 轴.我想要做的是改变我的 x 轴的范围,以显示时间而不是 t = 0.0002 * 迭代的迭代.
Since I am using that command line, it creates automatically a x-axis of length 30.000. What I would like to do is changing the range of my x-axis in such a way to show the time(s) instead of the iterations where t = 0.0002 * iteration.
推荐答案
你可以使用 linspace
:
You could use linspace
:
a=np.linspace(0,6,len(velocity_x))
plot(a, velocity_x, 'r' )
这篇关于如何在matplotlib中更改我的x轴范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文