I'm trying to plot values as a function of the date (only hh:mm:ss, without dd/mm/yy). The code looks like this
dates = matplotlib.dates.date2num(x_values)
plt.plot_date(dates, y_values)
but I get the following error
'numpy.string_' object has no attribute 'toordinal'.
date2num
expects datetime
objects. If you have strings, use matplotlib.dates.datestr2num
.
According to the docs:
matplotlib.dates.date2num(d): d is either a datetime instance or a sequence of datetimes.
Looks like you are giving in a string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With