我正在尝试绘制一个类似的图表,该图表显示在 plotly 示例页面 @ https://plotly.com/python/facet-plots/ 上,位于“将线条和矩形添加到分面图”部分下。矩形阴影仅绘制在图形的第一列上,但我希望在其余图形上可以看到相同的阴影。怎么办?
示例中使用的代码是:
import plotly.express as px
df = px.data.stocks(indexed=True)
fig = px.line(df, facet_col="company", facet_col_wrap=2)
fig.add_hline(y=1, line_dash="dot",
annotation_text="Jan 1, 2018 baseline",
annotation_position="bottom right")
fig.add_vrect(x0="2018-09-24", x1="2018-12-18", col=1,
annotation_text="decline", annotation_position="top left",
fillcolor="green", opacity=0.25, line_width=0)
fig.show()
尽管我已经在下面提供了我的发现并且没有删除我的帖子,因为希望与其他有类似困惑的新用户分享,但社区中仍有一位“有经验”的人为这篇帖子投了 -1 票。不过,我会继续分享。 :)
答案 0 :(得分:0)
实现示例中指定col=1的代码,导致阴影只出现在一个col图形上。