Black Lives Matter. Please consider donating to Black Girls Code today.

Cannot disable hoverinfo on a plotly express figure object

In the follwoing small Dash app:

df = pd.read_csv(...)
fig = px.line(x=.., y=.., color=..., template='presentation')
fig.update_traces(mode='lines+markers', hoverinfo='skip')
app = dash.Dash(__name__)
app.layout = htmlDiv([dcc.Graph(figure=fig)])

I still see hover popups on all traces, although I explicitly disable them via hoverinfo='skip'.

Do I have to use a call to another fig.update_.. method? I would like to keep the figure instantiation via fig = px.line(....

Thanks for any pointers.

Ah, sorry this is confusing… Plotly Express uses the new hovertemplate mechanism for its hovers, so you’ll also need to set hovertemplate=None alongside hoverinfo='skip' in your .update_traces() call.

1 Like

Thanks @nicolaskruchten. That works well.

I have a related question. In Plotly Express, I would like ONLY the text from hover_name to appear on my hover popups. I’ve tried various combinations with no success. How can I suppress the default hoverinfo and only show the bold text from hover_name?

The following still shows hoverinfo for color, x and y:

fig = px.scatter(boxplot_data, 
                 x="Current Applet Installs", 
                 y="Potential Applet Installs",
                 log_x=True, log_y=True,
                 color_discrete_sequence=["dodgerblue", "limegreen", "orange", "red"],

   # hovertemplate=None,


You can use string interpolation combined with the hovertemplate attribute in order to get the effect you are looking for.

import as px

hover_name = "hover_name"

fig = px.scatter(x=[1, 2, 3, 4, 5], 
                 y=[1, 2, 3, 4, 5],