StackOverflow

### Answer rating: 204

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 I plot time on the x axis and the numbers on the y-axis using Matplotlib?

I was trying to, but somehow it was only accepting arrays of floats. How can I get it to plot the time? Do I have to modify the format in any way?

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

Computer Age Statistical Inference: Algorithms, Evidence, and Data Science (Institute of Mathematical Statistics Monographs, Series Number 6). The twenty-first century has seen a breathtaking expan...

28/08/2021

Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems PDF, 2nd Edition. This book assumes you know next to nothing about m...

22/08/2021

We are witnessing a movement that will completely transform any part of business and society. The word we have given to this move- ment is Big Data and it will change everything, from the way banks an...

10/07/2020

Learn how data literacy is changing the world and giving you a better understanding of life's biggest problems in this "Important and Comprehensive" Guide to Statistical Thinking (New York). The bi...

28/08/2021

X
# Submit new EBook