Skip to content Skip to sidebar Skip to footer

How To Ad A Vertical Line To Matplotlib?

I want to show a vertical line at x='23:30:00'. I have tried x = '23:30' as well. Any ideas? df1 = df1.between_time('19:30','23:59') df1['high'].plot(kind='line',figsize = (10,5))

Solution 1:

You should pass the point you want the line in datetime format instead of the string you pass. Simply:

#datetimeformatinputplt.axvline(x= datetime.datetime(2017, 9, 25,23,30), color = 'r')

Result on a random dataframe:

enter image description here

Post a Comment for "How To Ad A Vertical Line To Matplotlib?"