Hi All,
I’m new to Plot.ly, and I am doing a 3D Scatter graph in Python now. In the hovertext box, I could not figure out "How to change X, Y, Z to the names I want? for example, change to “Apple”, “Pear”, “Banana”? I am using markers mode.
Thanks!
Hi @huanouliu,
You can accomplish this using the text
and hoverinfo
trace properties. See https://plot.ly/python/hover-text-and-formatting/#add-hover-text.
Here’s an example with Scatter3d
from plotly.offline import iplot, init_notebook_mode
import plotly.graph_objs as go
init_notebook_mode()
import numpy as np
x, y, z = [1, 2, 3, 4, 5], [1, 3, 5, 2, 4], [5, 4, 3, 2, 1]
trace1 = go.Scatter3d(
x=x,
y=y,
z=z,
mode='markers',
text=["Apple", "Pear", "Banana", "Peach", "Orange"],
hoverinfo = 'text',
marker=dict(
size=12,
line=dict(
color='rgba(217, 217, 217, 0.14)',
width=0.5
),
opacity=0.8
)
)
data = [trace1]
layout = go.Layout(
margin=dict(
l=0,
r=0,
b=0,
t=0
)
)
fig = go.Figure(data=data, layout=layout)
iplot(fig, filename='simple-3d-scatter')