我解决了我自己的问题。
Fig.layout.annotations 接受列表,每个箭头的参数是一个 dict()。所以想法是创建一个包含许多dict()的列表,然后使用fig.update_layout(annotations = list)来绘制多个箭头。
每个箭头的 dict() 如下所示:
arrow = go.layout.Annotation(dict(
x= x_end,
y= y_end,
xref="x", yref="y",
text="",
showarrow=True,
axref = "x", ayref='y',
ax= x_start,
ay= y_start,
arrowhead = 3,
arrowwidth=1.5,
arrowcolor='rgb(255,51,0)',)
)
可以像这样轻松创建多个箭头的列表:
list = list + [dict()]
然后,更新图:
fig.update_layout(
annotations= list_of_all_arrows,)
If all arrows are in time series, this is the final result: