Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何显示数据点和it';在Python3中,将标签悬停在Plotly中的折线图上时,是否一次删除标签?_Python_Python 3.x_Hover_Plotly_Linegraph - Fatal编程技术网

如何显示数据点和it';在Python3中,将标签悬停在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"],

我想在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"],
        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

谢谢你的详细解释。我一定会尝试其他可能的悬停方法。