如何显示数据点和it';在Python3中,将标签悬停在Plotly中的折线图上时,是否一次删除标签?
我想在PLOTLY中的折线图中添加数据点及其各自的标签,将其悬停在该折线图上时可见如何显示数据点和it';在Python3中,将标签悬停在Plotly中的折线图上时,是否一次删除标签?,python,python-3.x,hover,plotly,linegraph,Python,Python 3.x,Hover,Plotly,Linegraph,我想在PLOTLY中的折线图中添加数据点及其各自的标签,将其悬停在该折线图上时可见 import plotly.plotly as py import plotly.graph_objs as go data = [ go.Scatter( x = [1,2,3,4,5], y = [2,1,6,4,4], text = ["Text A", "Text B", "Text C", "Text D", "Text E"],
import plotly.plotly as py
import plotly.graph_objs as go
data = [
go.Scatter(
x = [1,2,3,4,5],
y = [2,1,6,4,4],
text = ["Text A", "Text B", "Text C", "Text D", "Text E"],
hoverinfo = 'text',
marker = dict(
color = 'green'
),
showlegend = True,textposition='top center'
)
]
py.iplot(data, filename = "add-hover-text")
然后我做了hoverinfo='y',显示如下:
我已经编写了代码,但是它显示了文本中定义的数据点或标签。我想同时展示这两个。您能帮我一次显示数据点及其标签吗。只需将您的
hoverinfo='text',
更改为hoverinfo='text+y',
hoverinfo
帮助说明:
The 'hoverinfo' property is a flaglist and may be specified
as a string containing:
- Any combination of ['x', 'y', 'z', 'text', 'name'] joined with '+' characters
(e.g. 'x+y')
OR exactly one of ['all', 'none', 'skip'] (e.g. 'skip')
- A list or array of the above
谢谢你的详细解释。我一定会尝试其他可能的悬停方法。