In matplotlib, how can I build a time series with the x axis as isoformat times?

I can find many examples of plot_date () and the like, but how can I build a time series where the x axis is the rows returned by datetime.time.isoformat ()? I use microsecond data, and this seems like a serious limitation.

+4
source share
2 answers

Although this is an old question, I would like to point out again a more detailed answer.

In principle, matplotlib can work independently with datetime.datetime objects. You can simply connect them as data. To correct your formation, use:

xfmt = matplotlib.dates.DateFormatter('%H:%M:%S:%f') ax.xaxis.set_major_formatter(xfmt) ax.plot(datetimes, data)

Adjust the format to suit your needs. A description of the directive directives can be found in the PythonLibrary in section 8.1.7.

+1
source

You can use the DATETICK command to add date strings to the x axis:

  >> datetick ('x', 'yyyy / mm / dd HH: MM: SS.FFF', 'keeplimits', 'keepticks')

You may need to adjust the date format for your purposes, and the "keeplimits" and "keepticks" options may or may not apply to your application.

0
source

Source: https://habr.com/ru/post/1340832/


All Articles