Format hovertemplate in go.Scattered3d

Folks please I ask your support to help me to set up hover template, I need to replace “x, y, z” for a new string. I ve tried to implement some posts from this community unsuccessfully. I really appreciate any orientation. Below is a fragment of code, where I tried to format the hover template.
vr_x_axis, vr_y_azis, vr_z_idx, vr_intersection_consolidate are lists used in the graphic.

fig = go.Figure(data=[go.Scatter3d(x=vr_x_axis, y=vr_y_axis, z=vr_z_idx,
                                       mode='markers+text',  # markers
                                       marker_size=8,
                                       customdata=np.stack((vr_x_axis,vr_y_axis,vr_z_idx, vr_intersection_consolidate),axis=-1),
                                       text=vr_intersection_consolidate,
                                       hovertemplatesrc="B: %{customdata[0]}"+\
                                                     "<br>Sl: %{customdata[1]}"+\
                                                     "<br>Sbl:%{customdata[2]}"+\
                                                     "<br>Qty:%{customdata[3]}",
                                       textposition='top center',
                                       textfont=dict(
                                           family='sans serif',
                                           size=12,
                                           color='red'
                                       ),
                                       marker=dict(
                                           size=4,
                                           color=vr_color,
                                           colorscale='Viridis', #plotly3
                                           opacity=0.5,
                                           reversescale=True))])

Hi @msal !
Welcome on the Forum! :tada:

Would be easier with a sample of your data, even with fake values, to have the shape and the type of your inputs and be able to make tests to check if anything else is wrong. :wink:

You used as customdata vr_x_axis | vr_y_axis | vr_z_idx | vr_intersection_consolidate
but as you also used them for x | y | z | text, you should be able to use them directly in hovertemplate.
You can try:

hovertemplate='''
B: %{x}
Sl: %{y}
Sbl: %{z}
Qty: %{text}
'''
1 Like

Skikis thank you so much for your replay, I implemented this change in my code, but the hover text in the graphic is showing the information as described below. This replacement not updated the hover text message.
Hover template in the graphic
x: test1
y: test2
z: test_sbl
120

It’s because you used hovertemplatesrc, the property is hovertemplate.

Here, slightly improved:

  hovertemplate='''
  B: %{x}<br>
  Sl: %{y}<br>
  Sbl: %{z}<br>
  Qty: %{text}
  <extra></extra>
  ''',

It works, I tested it with :

vr_x_axis = [1]
vr_y_axis = [1]
vr_z_idx = [1]
vr_intersection_consolidate = ['Cool']

image

You can remove customdata and chose between marker_size=8, and marker=dict(size=4), that sets the same property.

1 Like

Skikis thanks for your attention to support me in this process, I did the test in my original code and not work, but I did an extra test with your suggestion in a new graphic and it’s really worked well, maybe something in my code is impact the hover template, I shared the code below after the update with your suggestion.
I m updating the graphic with 1s intervals, I do know if it could impact the graphic properties.

def update_graph(n):
vr_x_axis, vr_y_axis, vr_z_axis, vr_z_idx, vr_z_name, vr_brk_description, vr_tick_vals, vr_intersection_consolidate = mgo.graphic(‘IND’)

vr_color = random.sample(range(1,30),10)

fig = go.Figure(data=[go.Scatter3d(x=vr_x_axis, y=vr_y_axis, z=vr_z_idx,
                                   mode='markers+text',  # markers
                                   marker_size=8,
                                   text=vr_intersection_consolidate,
                                   hovertemplate='''
                                   B: %{x}<br>
                                   Sl: %{y}<br>
                                   Sbl:%{z}<br>
                                   Qty:%{text}
                                   <extra></extra>
                                   ''',
                                   textposition='top center',
                                   textfont=dict(
                                       family='sans serif',
                                       size=12,
                                       color='red'
                                   ),
                                   marker=dict(
                                       size=4,
                                       color=vr_color,
                                       colorscale='Viridis', #plotly3
                                       opacity=0.5,
                                       reversescale=True))])

Hi @msal !
If you want more help, I will need more code and a sample of your data to try to detect where is the problem :slightly_smiling_face: