gpt4 book ai didi

python - 在 python : hover display doesn't differentiate along x axis? 中绘制

转载 作者:太空宇宙 更新时间:2023-11-04 02:21:00 24 4
gpt4 key购买 nike

我是 python 的新手,今天遇到了一个问题:当我绘制散点图时,悬停显示仅在点具有不同的 x 值时才有效。请参阅所附示例。

我试过将 hoverinfo 的格式设置为“x+y”,但没有任何区别。是否有解决方法,以便我可以显示具有不同 y 值但相同 x 值的条目?非常感谢您的帮助!

x=np.zeros(10)
y=np.arange(0,10,1)
trace1=go.Scatter(x=x, y=y)
data1=[trace1]
`enter code here`plotly.offline.iplot(data1)

只显示一个悬停标签: only one hover label shows up

最佳答案

尝试设置 hovermodelayout 中的 closest

import plotly
plotly.offline.init_notebook_mode()

x = [0] * 10
y = [y for y in range(0, 10)]
data = [plotly.graph_objs.Scatter(x=x, y=y)]
layout = plotly.graph_objs.Layout(hovermode='closest')
figure = plotly.graph_objs.Figure(data=data, layout=layout)
plotly.offline.iplot(figure)

enter image description here

关于python - 在 python : hover display doesn't differentiate along x axis? 中绘制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51620933/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com