我正在绘制三维散点图:
d = {'x':[1,2,3,4], 'y':[2,3,1,5], 'z':[3,2,3,2], 't':[4,1,2,3], 'score':[2,3,1,2]}
df = pd.DataFrame (d)
xtitle = 'x'
ytitle = 'y'
ztitle = 'z'
trace1 = go.Scatter3d(x=df[xtitle],
y= df[ytitle],
z = df[ztitle],
marker=dict(color=df['score'],
showscale=True,
colorbar=dict(
title='score)'
)),
mode='markers')
layout = go.Layout (
scene = Scene(
xaxis = dict (title = xtitle),
yaxis = dict (title = ytitle),
zaxis = dict (title = ztitle)
)
)
fig = go.Figure(data=[trace1], layout = layout)
plotly.offline.iplot(fig)
当我将鼠标悬停在一个点上时,它将显示x、y和z值。在
在数据框df
中,我有另一列名为t
,我希望当我将鼠标悬停在某个点上时,它也会显示x、y、z、t和score。在
我怎么能做到呢?在
使用hoverinfo参数。在
您可以在跟踪中使用
text
或hoverinfo
。在有用的链接:SO answer 0,SO answer 1,SO answer 2。您想要使用}。Here is the documentation。在
text
属性、hoverinfo
和{相关问题 更多 >
编程相关推荐