I have a list of datetime.date and a list of datetime.time values. I would like the date on the x axis and the time on the y axis.
x = [datetime.date(2018, 1, 15), datetime.date(2018, 1, 16), datetime.date(2018, 1, 17)]
y = [datetime.time(18, 15), datetime.time(17, 15), datetime.time(17, 47)]
When I try to plot the time on the y axis and the date on the x I get a numpy error:
"TypeError: float() argument must be a string or a number"
To get around it, I converted both values into datetimes, adding an arbitrary date to the time and a time of zero to the date:
x_new = [datetime.datetime.combine(d, datetime.datetime.min.time()) for d in x]
y_new = [datetime.datetime.combine(datetime.datetime.now().date(), t) for t in y]
That's fine, but when I plot this my y axis shows no minutes or seconds and instead has the format 'dd HH:MM'
e.g: '01 17:16' if I plot today. If I zoom in I can see the minutes and seconds, but that's no good. I want only hour, min, second to show, no date.
I hoped that using the plot_date option rather than just plot, I might find what I need, but that hasn't helped me.
I hope my question makes sense. Any help would be much appreciated. I saw an example where someone had their times formatted as strings, but I had some issues with that (another story), and I'd rather use datetimes really if possible.
Thanks!