Python 中的 Plotly 数据可视化入门
Alex Scriven
Data Scientist
$$

$$
add_annotation()$$
update_layout() 的 annotations 参数text:要显示的文本$$
x 和 y:注释的位置$$
showarrow = True/False:是否显示箭头$$
🛑 绝对定位要谨慎——数据变化可能导致重叠
x 和 y 指图中的数据值$$
xref 和 yref 设为 paper 可进行绝对定位x 和 y 为跨绘图区 0 到 1 的百分比x=0.5, y=0.5) 位于图中心
my_annotation = dict( x=215111, y=449000,showarrow=True, arrowhead=3,text="Our company is doing well", font=dict(size=10, color="black") )fig.update_layout(annotations=[my_annotation]) fig.show()
$$

$$
float_annotation = dict( xref="paper", yref="paper",x=0.5, y=0.8,showarrow=False, text="You should <b>BUY</b>", font=dict(size=15, color="black"), bgcolor="rgb(255,0,0)" )

Python 中的 Plotly 数据可视化入门