Scattergl points disappear when reaching a certain threshold in size difference
Open
Nobody has claimed this yet.
bug
P3
sev-2
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
I noticed, that in Scattergl points start to disappear from the graph when resizing and reaching certain thresholds in size difference.
Minimal example:
from dash import Dash, html, dcc, callback
from dash.dependencies import Input, Output
import plotly.graph_objects as go
from plotly.graph_objs import Scattergl
import numpy as np
import pandas as pd
np.random.seed(41)
x = np.random.uniform(-10, 10, 10)
y = np.random.uniform(-10, 10, 10)
sizes = np.random.uniform(0, 1000, 10)
df = pd.DataFrame({
'x': x,
'y': y,
'sizes': sizes
})
app = Dash(__name__)
app.layout = html.Div([
dcc.Slider(min=13, max=14, value=1, id='slider-sizes', step=0.1),
dcc.Graph(id='graph', style={"width": "100vw", "height": "80vh"}),
])
def update_marker_sizes(fig, size):
for trace in fig.data:
if 'marker' in trace and 'size' in trace.marker:
trace.marker.size = [s * size for s in trace.marker.size]
return fig
@callback(
Output('graph', 'figure'),
Input('slider-sizes', 'value')
)
def update_graph(size):
figure = go.Figure(data=Scattergl(x=df["x"], y=df["y"], mode='markers',
marker=dict(size=df['sizes']*size, sizemode='area')))
print(f"{50*'-'}\nslider size:{size}")
num_points = sum(
len(trace['x']) for trace in figure.full_figure_for_development()['data'] if
len(trace["x"]) > 1)
print(f"num points in dev data (x): {num_points}")
minsize, maxsize = float("inf"), float("-inf")
for trace in figure.data:
if hasattr(trace, 'marker') and hasattr(trace.marker, 'size'):
if len(trace.marker.size) > 1:
print(f"num points in data: {len(trace.marker.size)}")
minsize = min(minsize, min(trace.marker.size))
maxsize = max(maxsize, max(trace.marker.size))
print(f"min: {minsize}, max: {maxsize}, diff: {maxsize - minsize}")
return figure
if __name__ == '__main__':
app.run_server(debug=True, port=8000)
The points are still present in the underlying data structure:
Output:
--------------------------------------------------
slider size:13.5
num points in dev data (x): 10
num points in data: 10
min: 1350.4235691765416, max: 10008.250444470288, diff: 8657.826875293747
--------------------------------------------------
slider size:13.6
num points in dev data (x): 10
num points in data: 10
min: 1360.4267067259975, max: 10082.385632947846, diff: 8721.958926221849
--------------------------------------------------
slider size:13.5
num points in dev data (x): 10
num points in data: 10
min: 1350.4235691765416, max: 10008.250444470288, diff: 8657.826875293747
--------------------------------------------------
Visually, this is what happens:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the minimal Dash example from the issue and varying the slider around the reported size thresholds. Trace the Scattergl rendering path to determine why points disappear despite remaining in the data, then verify that all points remain visible across the reproducing size range.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100