[英]Plotly: Is it possible to color specific portion of the line in line chart?
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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.