How to add 'hovermode' options to modebar?


This is a follow up question to the following post. I am adding more details in this question hoping it help to get an answer.

Even if Plotly cannot do it under certain circumstances, It helps me to know, so I won’t spend time to keep lookking for it.

Updated question with additional detail:

I learned that I can add some really useful options to Plotly’s modebar using a code like this:

import plotly.graph_objects as go
import as px
df =
fig = px.scatter(df, x='petal_width', y='sepal_length', color='species')
    title_text='Draw a path to separate versicolor and virginica',

However, still I am looking for options to add the hovermode options (like fig.update_layout(hovermode="x unified") ) to the modbar. On youtube I’ve seen people have the hovermode buttons on the modbar like the following screenshot:


How can I add buttons pointed above to my Plotly Python scatter charts?

Any help would be appreciated,

Hi @python-trader

The buttons you have highlighted can be added with:


Hi @atharvakatre ,

That’s it! Thank you.

For the benefit of the community, and of the following code would conflict (or make it invisible) with ‘toggleSpikeLines’. It took me sometime to figure out the conflict:

fig.update_xaxes(showspikes=True, spikemode="across")
fig.update_yaxes(showspikes=True, spikemode="across")

 fig.update_layout(hovermode="x unified")