Repository navigation
Description
Description
AnnZarro is an open viewer for single-cell data. It draws 1 million to 100 million points with plotly.js. At that size, plotly.js main (df22b38) reaches these limits:
- A scatter3d trace of 2,000,000 points does not load.
Plotly.newPlotrejects it withRangeError: Invalid typed array length: 624000000(see also scatter3d plot with 1.5M points gives RangeError: attempting to construct out-of-bounds TypedArray on ArrayBuffer plotly/plotly.js#4589). - 2,000,000 scatter3d points in ten traces open in about 3,650 ms (median of four runs) and hold 8,320 MB of GPU buffers
- 5,000,000 scatter3d points in ten traces open in 8,077 ms and hold 20,800 MB of GPU buffers
- A recolor of one of these traces uploads the 8,320 MB again and takes about 3,240 ms
- Translucent scatter3d markers blend in trace order, not by depth (scatter3d points aren't ordered by depth across traces plotly/plotly.js#1267)
- The outline of a scatter3d marker stays about 1 pixel wide for each
marker.line.width(3D Scatter Plot marker->line->width attribute appears to be broken on some hardware plotly/plotly.js#3796) - Each rotation frame of a 3D scene draws every trace two times: 20 draw calls for ten traces
- 20,000,000 scattergl points open in 3,918 ms, and a recolor of one trace takes 3,778 ms and uploads 680 MB
- 50,000,000 scattergl points open in 11.7 s, and the browser tab then crashes at the first pan
- A pan of scattergl traces under
scaleanchorrecalculates every trace: 908 ms for each step at 5,000,000 points
Conditions: Apple M3 Max, headless Chromium on ANGLE Metal, 1200 x 800 px. Each plot holds ten traces of opaque markers of size 3 with Float32Array input, and hover is off in 2D. Each number is one run, unless the item says median.
Why should this feature be added?
Each limit has a cause in the code, and a change that removes the cause.
- Marker meshes. A scatter3d circle marker is a glyph mesh of 104 vertices, 60 for the fill and 44 for the outline. That is 4,160 bytes of vertex data per marker, and a trace of 2,000,000 markers exceeds the typed array limit. One point sprite per circle marker is sufficient, and a marker without an outline needs no outline vertices.
- The outline. The outline is a GL line, and Chrome with ANGLE draws a GL line 1 pixel wide. A fragment shader can draw the ring of a point sprite with the width that
marker.line.widthsets. - One array per point.
convert.jsbuilds one small array for each scatter3d point. Typed x, y and z can go to the GPU as oneFloat32Array. An edit that keeps the positions then uploads no position. - Transparency. The scene blends translucent markers in draw order. A fixed number of depth layers per pixel can weight each fragment by the markers in front of it. Then the draw order has no effect, and the scene sorts nothing.
- The pick pass. The scene draws the pick pass in each frame, but only a pointer event reads the pick buffer. The scene can draw the pass when an event asks for it.
- scattergl copies.
calcand regl-scatter2d copy each point several times and upload 16 bytes of positions per point, also for a recolor or a reorder. AFloat32Arraycan go to the GPU one time with 8 bytes per point. A trace of 100,000 points or more also gets a hover tree at every calc (see [BUG]:scatterglhover is slow above 100k points plotly/plotly.js#8134). The first hover can build that tree. - Constrained axes. A range change under
scaleanchorsets the recalc flag. With fixed ranges, a replot applies the constraint, and no recalc is necessary. - Tens of millions of points. One full draw of 50,000,000 points takes too long for a pan frame. A thinned preview can follow the pointer, and the full picture can follow at rest.
- WebGL contexts. Each scattergl graph creates two WebGL contexts, and the second context shows only selected points. The graph can create that context when a selection starts.
- Marked points. Points in front hide marked points inside a dense cloud, such as a selection. A trace attribute can keep one trace on top, without a depth test.
Which of these changes do you want in plotly.js, and in which form? We have a prototype for each one on our fork. After your choice, we open small pull requests, one per change. Thank you for your time.
Mocks/Designs

plotly.js main alone: time to the first frame and GPU buffers against the number of points. The red X marks where the plot stops. In 3D, that is a RangeError from 2M points per trace. In 2D, the tab crashes at 50M points. Not run: 100M and more in 3D, and 1M, 2M and 100M in 2D.
Notes
- Related issues: scatter3d points aren't ordered by depth across traces plotly/plotly.js#1267 (transparency order), 3D Scatter Plot marker->line->width attribute appears to be broken on some hardware plotly/plotly.js#3796 (outline width of scatter3d markers), Scatter 3d - Geometric position not respected i.e. a dataset added later appears on top even if it is behind spatially. plotly/plotly.js#6536 (closed, same as scatter3d points aren't ordered by depth across traces plotly/plotly.js#1267)
- scatter3d plot with 1.5M points gives RangeError: attempting to construct out-of-bounds TypedArray on ArrayBuffer plotly/plotly.js#4589 (closed in 2020): a scatter3d plot of 1.5M points fails with the same
RangeError - [BUG]:
scatterglhover is slow above 100k points plotly/plotly.js#8134 (open): scattergl hover is slow above 100k points. The open pull request Fix: Performance for greater than 100k points on hover in scattergl plotly/plotly.js#8198 changes the same hover tree. - plotly.js 2.35.3 gives the same error and the same times as
main, within 4 percent - The 3D changes need changes in gl-plot3d and gl-scatter3d, and the scattergl changes need a change in regl-scatter2d
- We measured on one machine. The 2D numbers at 20M points come from a strict bundle.
- AI agents wrote most of the prototype code and this text. We reviewed the code and looked at each rendered plot.
- This text quotes one error string and the attribute names as the code spells them
Contribution
- I want to open a pull request for this issue after it gets the
ready-for-prlabel - I can review or test a pull request from someone else
Activity
[-][DRAFT for plotly.js] [FEATURE]: Large and translucent point clouds in scatter3d and scattergl[/-][+]Issue to file: [FEATURE]: Large and translucent point clouds in scatter3d and scattergl (overview)[/+][-]Issue to file: [FEATURE]: Large and translucent point clouds in scatter3d and scattergl (overview)[/-][+][FEATURE]: Large and translucent point clouds in scatter3d and scattergl[/+]