I am trying to plot a vertical line using axvline
but ending up with the following error.
Update: the question deviates from posted references because only discreet x-axis tick locations are used (as stated by Trenton McKinney).
Error
TypeError: '<' not supported between instances of 'Timestamp' and 'numpy.float64'
Code
import pandas as pd
df = pd.DataFrame({'A': {0: '2020-01-01 06:00:00',
1: '2020-01-01 18:00:00',
2: '2020-01-02 06:00:00',
3: '2020-01-02 18:00:00',
4: '2020-01-03 06:00:00',
5: '2020-01-03 18:00:00',
6: '2020-01-04 06:00:00',
7: '2020-01-04 18:00:00'},
'B': {0: 5, 1: 5, 2: 6, 3:6, 4:7, 5:7, 6:1, 7:1}})
df['A'] = pd.to_datetime(df['A'])
df= df.set_index('A')
ax = df.plot.bar()
ax.axvline(pd.to_datetime('2020-01-02 18:00:00'), color='grey', zorder=1, linestyle='--', marker="v" )
ax.axvline(pd.to_datetime('2020-01-03 00:00:00'), color='grey', zorder=1, linestyle='--', marker="v" )