I am forecasting Covid cases and using Plotly for visualization. I would like to plot a straight vertical line in place where forecast starts. I have a chart like this. chart. I just want to plot a vertical line on date 25 Jan 2021, so it is visible where forecast starts.
I managed to make it work with text annotations by converting it back to milliseconds as suggested here
Here is the example code:
import plotly.express as px
import datetime
df = px.data.stocks(indexed=True)
fig = px.line(df)
fig.add_vline(x=datetime.datetime.strptime("2018-09-24", "%Y-%m-%d").timestamp() * 1000, annotation_text="test" )
fig.show()
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