Plotting time in Python with Matplotlib

前端 未结 4 1591
忘掉有多难
忘掉有多难 2020-11-22 09:04

I have an array of timestamps in the format (HH:MM:SS.mmmmmm) and another array of floating point numbers, each corresponding to a value in the timestamp array.

Can

4条回答
  •  时光取名叫无心
    2020-11-22 09:33

    You must first convert your timestamps to Python datetime objects (use datetime.strptime). Then use date2num to convert the dates to matplotlib format.

    Plot the dates and values using plot_date:

    dates = matplotlib.dates.date2num(list_of_datetimes)
    matplotlib.pyplot.plot_date(dates, values)
    

提交回复
热议问题