Matlibplot 阶跃函数索引 0 [英] Matlibplot step function index 0

查看:66
本文介绍了Matlibplot 阶跃函数索引 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用matplotlib的step函数对此进行绘制

Hi I am trying to plot this using matplotlib's step function

from matplotlib.pyplot import step, show, xlim

time = [0.0, 0.0, 0.0, 25.3039, 25.5539, 25.8049, 45.8699, 46.1209, 46.3719, 46.6229, 63.1719, 63.4239, 63.6749, 79.9779, 80.2289, 80.4799, 80.7309]
value = ['0', '0', '0', '93', '940', '951', '940', '437', '422', '421', '423', '598', '605', '192', '3', '1', '0']

xlim(0, 145)
step(time,value)

show()

我希望阶梯函数将绘图显示为 0,并从 25.3039 时间开始从 93 开始.相反,我从时间 0 开始看到值 93,如图所示.我需要保持时间轴从0开始,因此我无法真正将xlim更改为从25.3039开始.

I am hoping the step function will show the plot to be 0 and starts at 93 from time 25.3039. Instead I see value 93 from time 0 as shown in the graph. I need to keep the timeline to start from 0 so I can't really change my xlim to start from 25.3039

我该怎么做才能解决此问题?任何帮助将不胜感激!

What should I do to fix the issue? Any help will be appreciated!

谢谢!

推荐答案

您需要设置步骤应在何处执行(

You need to set where step should step (doc). The default is that the locations are interpreted as the right edge, you want the locations interpreted as the left edge.

step(time,value,where='post')

请参阅matplotlib 中的步进函数以获得更长的解释/示例.

See Step function in matplotlib for a longer explanation/example.

这篇关于Matlibplot 阶跃函数索引 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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