-1

I want to use Python's plt.scatter or ax.scatter to show a car finishing times as scatterplot chart. So my x axis contains an array:

'car001','car002','car003', ...

The y axes should contain the finish time in datetime format like:

'2019-01-01 23:32:01','2019-01-01 23:32:01','2019-01-01 23:32:01', ...

Why it is so difficult to use datetime values as pandas dataframe with a scatterplot? I don't want to use plt.plot() with linestyle 'o'.

Thank you very much!

Jona
  • 1,218
  • 1
  • 10
  • 20
phpler
  • 9
  • 3
  • This question might help you : https://stackoverflow.com/questions/38256750/make-a-scatter-plot-in-matplotlib-with-dates-on-x-axis-and-values-on-y – Jona Oct 25 '19 at 14:32

1 Answers1

0

Did you try something like this ?

import pandas as pd
import matplotlib.pyplot as plt

dates = ['2017-01-01 23:32:01','2018-01-01 23:32:01','2019-01-01 23:32:01']  
PM_25 = ['car001','car002','car003']
dates = [pd.to_datetime(d) for d in dates]

plt.scatter(dates, PM_25)
plt.show()
Jona
  • 1,218
  • 1
  • 10
  • 20