plotly.py
plotly.py copied to clipboard
Hover tooltip works incorrectly in scatter WebGL
In the code example below (using the scattergl) when the cursor is rolled over the bubble, the hover tooltip does not appear until the cursor is close to the center of the bubble. The tooltip itself also points to the center of the bubble.
This is different from the expected behavior observed with the regular scatter where the tooltip appears in relation to the boundary of the bubble, rather than its center. And the tooltip points to the boundary as well.
For the Plotly Express px.scatter, one needs to set render_mode='svg' to switch out of WebGL for the correct behaviour.
This results in an incorrect tooltip in WebGL appearing when the cursor is over the larger bubble in an example such as this one:

import pandas as pd
import plotly.graph_objects as go
df = pd.DataFrame({'x': [1], 'y': [1],'z': [100]})
fig = go.Figure()
fig.add_scattergl(
x=df['x'],
y=df['y'],
marker_size=df['z'],
mode='markers',
marker_sizeref=0.01,
marker_sizemode='area',
showlegend=True,
hovertemplate=(
'x: %{x:.2f}<br>'
'y: %{y:.2f}<br>'
'<extra></extra>'
),
)
fig.show()