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()
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With