0

I would like to add more hover text using multiple columns for my 3D plot model.

For example: df:

    sepal_length    sepal_width petal_length    petal_width species species_id
0   5.1             3.5         1.4             0.2         setosa  1
1   4.9             3.0         1.4             0.2         setosa  1
2   4.7             3.2         1.3             0.2         setosa  1
3   4.6             3.1         1.5             0.2         setosa  1
4   5.0             3.6         1.4             0.2         setosa  1
5   5.4             3.9         1.7             0.4         setosa  1

Code:

import plotly.express as px
df = px.data.iris()
fig = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width',
                    color='petal_length', symbol='species', hover_name="species")
fig.show()

produced plot enter image description here

In the plot, the hover_name="species" shows only species in the hover_name. How can I include species_id in hover_name as well?

1 Answer 1

2

Simply add additional information in hover_data argument below:

import plotly.express as px
df = px.data.iris()
fig = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width',
                    color='petal_length', symbol='species', hover_name="species", hover_data=["species", "species_id"])
fig.show()

Docs could be found here Customizing Hover text with Plotly Express

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.