Choosing Between Plotly.js Scatter and Scattergl for Large‑Scale Point Clouds
Plotly.js offers Scatter (SVG) and Scattergl (WebGL). This guide helps decide which to use for large point sets, comparing performance, memory, features, and providing a step‑by‑step validation plan.
05 Jul 2026, 00:26 UTC

Decision: Which Plotly Scatter Type to Use?
When you need to plot a large number of points – from a few thousand to millions – you can choose between the classic Scatter trace (SVG‑based) and the GPU‑accelerated Scattergl trace (WebGL). The decision hinges on three main constraints:
- Dataset Size – How many points will you render?
- Target Devices – What GPU and memory are available?
- Feature Requirements – Do you need advanced SVG features like per‑point annotations?
Use Scattergl when you need high‑performance interaction with very large point clouds and your users have reasonably modern GPUs. Use Scatter when you need guaranteed compatibility on low‑end devices or when you require complex SVG‑only features.
Constraints in Practice
- WebGL Availability – Corporate browsers may block WebGL. Enable it with
config: {gl: 'webgl'}or rely on Plotly’s auto‑fallback. - GPU Memory Limits – Devices with < 2 GB VRAM can stall or crash when rendering millions of points. Monitor GPU usage with browser dev tools or OS utilities.
- 3D Requirement –
Scattergldoes not support 3D plots. UseScatter3dinstead.
Compact Comparison Table
| Feature | Scatter (SVG) | Scattergl (WebGL) |
|---|---|---|
| Rendering Engine | CPU‑based SVG | GPU‑based WebGL |
| Typical Max Points | ~10 k before jank | 100 k+ (up to millions) |
| Interaction Smoothness | High for <10 k points | Stable >30 fps for large sets |
| Memory Footprint | CPU memory only | GPU memory + CPU overhead |
| Advanced SVG Features | Full support (text, annotations) | Limited – no DOM annotations |
| 3D Support | No | No |
| Automatic Fallback | N/A | Yes – falls back to Scatter if WebGL unavailable |
| Browser Compatibility | All modern browsers | Requires WebGL support |
Trade‑Offs Explained
- Performance vs Compatibility
- Scattergl gives near‑real‑time pan/zoom for huge datasets but will not render if WebGL is disabled. Scatter remains functional everywhere.
- Memory vs Feature Richness
- Scattergl consumes GPU memory; on low‑VRAM machines it can freeze. Scatter uses only CPU memory but can’t render complex per‑point labels.
- Ease of Implementation
- Both traces share the same API; switching is as simple as changing the trace type. However, you may need to adjust marker sizing or color scales to suit GPU limits.
Concrete Implementation & Validation Strategy
Below is a step‑by‑step plan to decide which trace type to ship. It includes a sample code snippet, performance checks, and GPU memory monitoring.
1. Prepare a Benchmark Dataset
// Generate 1,000,000 random points
const n = 1_000_000;
const x = Array.from({length: n}, () => Math.random() * 100);
const y = Array.from({length: n}, () => Math.random() * 100);
2. Render with Scattergl
const traceGl = {
x, y,
mode: 'markers',
type: 'scattergl',
marker: {color: 'steelblue', size: 3}
};
Plotly.newPlot('glDiv', [traceGl]);
Run this in Chrome or Firefox. Open DevTools → Performance. Perform a pan or zoom, then check the frame rate. A smooth experience is indicated by a stable >30 fps line.
3. Monitor GPU Memory
On Windows, open Task Manager → Performance → GPU Memory. Verify that the plot stays below ~1.5 GB on a 2 GB VRAM laptop. On macOS, use Activity Monitor → GPU tab.
4. Fallback Test
// Force WebGL off
const config = {gl: false};
Plotly.newPlot('fallbackDiv', [traceGl], {}, config);
The plot should render using SVG, albeit slower. Confirm by measuring load time and interaction lag.
5. Compare with Scatter
const traceSvg = {
x, y,
mode: 'markers',
type: 'scatter',
marker: {color: 'steelblue', size: 3}
};
Plotly.newPlot('svgDiv', [traceSvg]);
Repeat the performance and memory checks. Expect higher load times and frame drops for large datasets.
6. Decision Checklist
- Did Scattergl maintain >30 fps during interaction on target hardware?
- Did GPU memory stay within safe limits?
- Do you need per‑point annotations or complex SVG text?
- Is WebGL reliably available in your user environment?
If the answer to (1) and (2) is yes and (3) is no, choose Scattergl. Otherwise, fall back to Scatter.
Practical Tips & Caveats
- Use
marker: {size: 1}for millions of points; larger markers cause GPU fragmentation. - When combining
Scatterglwith other trace types, keep the total GPU memory usage below 80 % of your device’s VRAM. - For corporate environments, add a user‑friendly message if WebGL is disabled:
config: {gl: 'webgl', displayModeBar: false}will automatically fall back. - Always test on the lowest‑end device you expect to support before releasing.
Conclusion
Plotly’s Scattergl is the go‑to choice for interactive visualizations of large point clouds, offering GPU‑accelerated rendering and smooth user experience. However, it comes with higher GPU memory demands and limited SVG‑only features. The classic Scatter trace remains the safest fallback for compatibility and advanced text annotation needs. By following the benchmark steps above, you can objectively determine which trace type aligns with your performance goals and target hardware profile.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.