Hi I have a dataframe with time series on my x axis and values on my y axis. I am using Plotly and am trying to plot a vertical line on the x axis where there my df.Alert == 1. Currently I am using another overlay with red marker to plot it but I wish to switch to a vertical line that is restricted within by the y values of my chart. The values on the y axis should still be determined by my trace plot and not the vertical line.
Is there a way for me to do this?
My code sample is written below
Blockquote
Trace = go.Scatter(
name = “Values”,
x = df.DateTime,
y = df.Values,
mode=‘markers’,
text= "Unit: " + df[‘Unit’].astype(str),
)
Alert = go.Scatter(
name = “Alert”,
x = df.DateTime,
y = df.Values.where(df.Alert == 1),
mode=‘markers’,
line = dict(color = “red”),
text= "Unit: " + df[‘Unit’].astype(str),
)
layout = go.Layout(
xaxis = dict(title = “Date and Time”),
yaxis = dict(title = “Values”)
)
data = [Trace, Alert]
figure = go.Figure(data = data, layout = layout)
py.iplot(figure)
Blockquote