Sphere
Log in Join
☆ 4

altair chart too slow with 50000 rows in jupyter

Altair 5.2 in JupyterLab, plotting 50,000 rows as a scatter. It takes ~15 seconds to display and panning/zooming is sluggish. I know Altair is built on Vega-Lite and there's a max rows default of 5000, but I raised it with alt.data_transformers.enable('default', max_rows=None). The chart embeds the whole dataset as JSON in the notebook, which I think is the problem. Is there a way to use a data server or send the data separately? Also would switching to the 'json' or 'vegafusion' transformer help?

⚑ Report

4 replies

☆ 0
O offbyone ·2026-11-11#1

Embedding 50k rows as inline JSON is the bottleneck. The modern answer is the vegafusion data transformer: alt.data_transformers.enable('vegafusion') (install vegafusion-python-embed and vl-convert-python). VegaFusion pushes aggregation and transforms to a Rust server so the browser isn't parsing a huge JSON blob; it handles large data much better. The 'json' transformer writes data to a separate file rather than inlining, which helps notebook size but not interactivity. For selection interactions, vegafusion is the one to use.

⚑ Report
☆ 0
C cod ·2026-11-12#2

vegafusion isn't installed - I'll pip install it. Does it work in JupyterLab without extra config, or do I need to register a mime renderer too? And if I also want to save the chart as a standalone HTML to email to people, does vegafusion break that since it needs a server? Our ops team doesn't run Jupyter, so a static export still matters.

⚑ Report
☆ 0
G green ·2026-11-13#3

In JupyterLab, vegafusion works with the vegafusion-jupyter package which registers the mime renderer - install both. For standalone HTML, the chart will embed the data (vegafusion is a live server feature) so it falls back to an embed but still renders; use vl-convert to save as HTML/SVG/PNG. Common pattern: vegafusion for interactive notebook work, and for sharing export a static PNG via vl-convert or a separate HTML with the data downsampled.

⚑ Report
☆ 0
S skill ·2026-11-14#4

Installed vegafusion and vegafusion-jupyter, display time dropped to ~2s and interactions are smooth. For sharing I export a PNG with vl-convert and keep the interactive version in the notebook. If you're stuck with altair being slow on >10k rows, the data transformer is the fix - 'default' inlines everything into the notebook output, which is why it crawls. vegafusion is the current recommended path.

⚑ Report
Log in to reply.