✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Unified hovermode with sublots

Hi, I was wondering if is it possible to have the new unified hovermode working in the case we have subplots

from plotly.subplots import make_subplots
import plotly.graph_objs as go
import plotly.express as px

df = px.data.gapminder().query("continent=='Oceania'")

countries = df["country"].unique()

fig = make_subplots(rows=len(countries), cols=1, shared_xaxes=True)
for i,country in enumerate(countries):
    fig.add_trace(go.Scatter(x=df[df["country"]==country]["year"],
                             y=df[df["country"]==country]["lifeExp"],
                             name=country),

                      i+1,1)

fig.update_layout(hovermode="x unified")
fig.show()

I’ve an hovermode in every subplots but I’d like to have a straight line that go across subplots.

Hi @baobob, the “x unified” hovermode does not work (yet) across subplots. We have an open issue for this which you can subscribe to https://github.com/plotly/plotly.js/issues/4755. If you’re only interested in the spike line extended to the other subplots you can do this with

fig.update_traces(xaxis='x1')

(imposing that there is only one xaxis)
but this will just give you the extended spike line, not the hover information of all subplots.

1 Like

@Emmanuelle thanks. What I’d like to achieve is similar to Spain, confirmed weekly deaths plot in Economist