Sample line chart
import plotly.express as px
df = px.data.stocks()
fig = px.line(df, x='date', y="GOOG")
fig.show()
I want to color the values > 1.1
and values<0.95
to a different color(ex: red)
Is it possible in plotly to color the specific portion of the line into a different color?
import plotly.express as px
df = px.data.stocks()
fig = px.line(df, x="date", y="GOOG").add_traces(
px.line(
df.loc[~df["GOOG"].between(0.95, 1.1)].merge(
df, on="date", how="right", suffixes=("", "_r")
),
x="date",
y="GOOG",
)
.update_traces(line_color="red")
.data
)
fig.show()