3

I have time tagged data formatted using datetime.datetime.strptime that includes milliseconds. The data can span from a few minutes to a few hours. When I plot using pyplot and zoom in, it seems the minimum tick mark is 1 second. It appears that matplotlib's TickHelper RRuleLocator only has a SecondLocator. Is there a way to include millisecond resolution when zoomed in?

receivedTime = datetime.datetime.strptime(str(data[1]), "%H:%M:%S.%f")

fig=plt.figure()
ax=fig.add_axes([0.1,0.1,.8,.8])
fig.autofmt_xdate()

ax.plot(times, prices, color='blue', lw=1, drawstyle='steps-post', label = prices)
plt.show()

1 Answer 1

1

Matplotlib uses Matlab like numbers (seconds since 1970) for dates. If you have milliseconds, you must convert the dates to 'number':

import matplotlib.dates as mdates
ntimes = mdates.num2epoch(times / 1000.0)

and plot ntimes instead of times.

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.