i would like to plot the times from a datetime64 series, where the y-axis is formatted as \'%H:%M, showing only 00:00, 01:00, 02:00, etc.
this is what the plot look
For that to work you need to pass datetime
objects (and I mean datetime
, not datetime64
). You can convert all timestamps to the same date and then use .tolist()
to get the actual datetime
objects.
y = df['a'].apply(lambda x: x.replace(year=1967, month=6, day=25)).tolist()
ax = plt.subplot()
ax.plot(df.index, y)
ax.yaxis.set_major_locator(HourLocator())
ax.yaxis.set_major_formatter(DateFormatter('%H:%M'))