import plotly.plotly as py
import plotly.graph_objs as go
trace1 = go.Scatter(
x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
y=[0, 1, 3, 2, 4, 3, 4, 6, 5]
)
trace2 = go.Scatter(
x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
y=[0, 4, 5, 1, 2, 2, 3, 4, 2]
)
data = [trace1, trace2]
layout = go.Layout(
showlegend=False,
annotations=[
dict(
x=2,
y=5,
xref='x',
yref='y',
text='max',
showarrow=True,
arrowhead=7,
ax=0,
ay=-40
)
]
)
fig = go.Figure(data=data, layout=layout)
iplot(fig)
参考链接: https://plot.ly/python/text-and-annotations
希望这能回答你的问题。在散点图中,请参考mode='lines+markers+text'
(在plotly文档的Adding Text to Data in Line and Scatter Plots
部分)。保留HTML标签。虽然现在有点晚了,但是请查看dash-bootstrap-components中的dbc.Input。
https://dash-bootstrap-components.opensource.faculty.ai/l/components/input
有表单类型、输入框等。
我的做法是添加一些输入框和提交按钮。提交按钮将触发创建图形、添加相关内容并将图形返回到图表的函数。