1

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

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!

Thanks!

1 Answer 1

4

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.