How to customize the hovering text when it is another column rather than the columns introduced for axes?

Hey @Peyman , I can’t verify this right now, but you might be able to use the customdata argument.

EDIT it works:

import plotly.express as px
import plotly.graph_objects as go
import pandas as pd

# datasource
df = px.data.iris()

color_dict = {1:'red',2:'blue',3:'green'}
colors = [color_dict[i] for i in df.species_id]

# create figure + trace
fig = go.Figure()
fig.add_scatter3d(
    x=df.sepal_length, 
    y=df.sepal_width, 
    z=df.petal_width,
    # here the additional data is added
    customdata=[f'text_{i}' for i in range(df.shape[0])],
    hovertemplate="<b><i>Z</i>: %{z:.2f}</b>" + "<br><b><i>%{customdata}</i>",
    mode='markers',
    marker_size=5,
    marker_color=colors
)
fig.update_layout(width=500, height=500)

creates:

2 Likes