plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

Hoversubplots=axis not working with make_subplots

Open Coding-with-Adam opened this issue 1 year ago • 14 comments

Initially reported on the Plotly forum.

Using make_subplots means that the hoversubplots=“axis” will not work correctly.

Sample code that produces the error: Codepen.

import plotly.graph_objects as go
from plotly import data
from plotly.subplots import make_subplots

df = data.stocks()


fig = make_subplots(rows=3, cols=1, shared_xaxes=True, vertical_spacing=0.03)
layout = dict(
    hoversubplots="axis",
    title="Stock Price Changes",
    hovermode="x",
    grid=dict(rows=3, columns=1),
)

fig.add_trace(go.Scatter(x=df["date"], y=df["AAPL"], name="Apple"), row=1, col=1)
fig.add_trace(go.Scatter(x=df["date"], y=df["GOOG"], name="Google"), row=2, col=1)
fig.add_trace(go.Scatter(x=df["date"], y=df["AMZN"], name="Amazon"), row=3, col=1)
fig.update_layout(layout)
fig.show()

bdc0bda148a0bc897f35bde5ac36eda09b53f731_2_1035x496

Expected behavior should be the same as when using the Plotly docs hover on subplots example, where hover labels appear for all charts: Codepen. image

Coding-with-Adam avatar May 06 '24 14:05 Coding-with-Adam

When will this be addressed?

Episkiliski avatar May 28 '24 14:05 Episkiliski

I have the same issues even with the latest Plotly 5.23.0

luweiming avatar Jul 29 '24 21:07 luweiming

+1 Many folks prefer not to work with the 'go' API because it's less intuitive. A fix for make_subplots would be appreciated 🙏

n-splv avatar Aug 19 '24 09:08 n-splv

+1 hitting the same issue, one cannot add multiple traces to a subplot and have the hoversubplots work at the same time

verdverm avatar Sep 10 '24 03:09 verdverm

+1, though I found https://community.plotly.com/t/hover-question-how-to-info-in-all-trace/84893/2 as well, which seems to indicate it's not a bug because (if I understand correctly) make_subplots(shared_xaxes=True) doesn't actually create a single x-axis?

"REMEMBER that setting shared_xaxes=True does not assign the same name to xaxis in all subplots."

matthiasschuurmans avatar Sep 11 '24 15:09 matthiasschuurmans

I have the same issues even with the latest Plotly 5.24.1

shifenhutu avatar Oct 20 '24 07:10 shifenhutu

Facing the same issue, hope this will get resolved soon

alsonpr avatar Oct 29 '24 03:10 alsonpr