I'm trying to create a vertical line on specific date, which is not part of my df weekly date index, and since it's not in the index, the plot is locating the vertical line on the next date that in the df index:
df=pd.DataFrame(index=pd.date_range('2020-01-01','2020-05-01',freq='W'),data={'val':range(0,17)})
ax=df.plot(grid=True,figsize=(12,6))
ax.set_xticks(df.index)
ax.set_xticklabels([x.date() for x in df.index],rotation=90)
ax.axvline(pd.Timestamp('2020-03-03'),ls='--',color='k')
as you can see, although I want to draw the line on '2020-03-03', it's created on '2020-03-08'.
Any ideas here? thanks:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.