Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotly 5.23.0, Hover on Subplots Only Work on one subplot #4701

Closed
luweiming opened this issue Jul 29, 2024 · 2 comments
Closed

Plotly 5.23.0, Hover on Subplots Only Work on one subplot #4701

luweiming opened this issue Jul 29, 2024 · 2 comments

Comments

@luweiming
Copy link

Hi All,

I'm using the latest Plotly 5.23.0

I've been trying days to make the Hover on Subplots work, and it turns out it didnt even work from the example/code listed on the plotly site https://plotly.com/python/hover-text-and-formatting/.

Anyone also encounter with the same issue? How to fix this? Thanks.

I'm using Windows 11, VScode, Jupyter Notebook or Python environment, none worked.

import plotly.graph_objects as go
import pandas as pd
from plotly import data

df = data.stocks()

layout = dict(
hoversubplots="axis",
title="Stock Price Changes",
hovermode="x",
grid=dict(rows=3, columns=1),
)

data = [
go.Scatter(x=df["date"], y=df["AAPL"], xaxis="x", yaxis="y", name="Apple"),
go.Scatter(x=df["date"], y=df["GOOG"], xaxis="x", yaxis="y2", name="Google"),
go.Scatter(x=df["date"], y=df["AMZN"], xaxis="x", yaxis="y3", name="Amazon"),
]

fig = go.Figure(data=data, layout=layout)

fig.show()

@LiamConnors
Copy link
Contributor

Hi @luweiming, if you hover over the Plotly logo in the graph, what version of Plotly.js do you see?

image

VS Code doesn't use the installed Plotly.py version of Plotly.js by default. It uses its own bundled Plotly.js, which can often be behind the latest in Plotly.py. The hover on subpplots feature was introduced in Plotly.js 2.31.0.

This gives some more context on the issue https://plotly.com/python/troubleshooting/#vscode-notebook-nteract-and-streamlit-problems

Setting the renderer on fig.show to "notebook" is a workaround if you see it's not using the latest Plotly.js

fig.show(renderer="notebook")

@luweiming
Copy link
Author

Hi @LiamConnors, Thanks so much for the help, this is interesting and no wonder I have so many weird issues on Plotly. My Plotly.js was 2.29.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants