XY Python Charting Library: GPU-Accelerated Visualization for Large Datasets
XY Python Charting Library: GPU-Accelerated Visualization for Large Datasets
XY is a GPU-accelerated Python charting library designed for high-performance interactive visualizations across the web, notebooks, and static exports. By shifting heavy computation to a Rust core and utilizing WebGL2 for rendering, XY enables the visualization of massive datasets—including a 10-billion-point OpenStreetMap dataset—while maintaining sub-second responsiveness for panning, zooming, and hovering.
High-Performance Rendering Architecture
XY achieves its speed by avoiding the common bottleneck of serializing every data point as JSON for browser-side rendering. Instead, it employs a multi-stage pipeline to minimize data transfer and maximize rendering efficiency:
- ColumnStore: Exact values are maintained in a
ColumnStoreon the Python side. - Rust Compute Core: A native Rust core computes the necessary level of detail based on the current screen resolution. It generates either direct, decimated, or density views.
- Typed Binary Buffers: Instead of JSON, XY transfers compact typed binary buffers to the browser.
- WebGL2/Canvas Rendering: The browser uses WebGL2 for marks and Canvas for axes and DOM interfaces.
When dealing with large datasets, XY draws a screen-bounded density surface rather than individual markers. As a user zooms in, the Rust core re-computes the view for the new range, eventually drilling down to the exact original rows.
Performance Benchmarks
In benchmarks conducted on an Apple M5 Pro, XY demonstrates significantly lower render times and memory usage compared to Matplotlib (WebAgg) and Plotly (scattergl) as dataset sizes scale.
Render Time (Time until every point is on screen)
| Points | XY | XY (density=False) | Matplotlib | Plotly |
|---|---|---|---|---|
| 10k | 0.071s | 0.085s | 0.086s | 0.341s |
| 1M | 0.084s | 0.098s | 0.357s | 0.614s |
| 10M | 0.083s | 0.206s | 2.804s | 3.367s |
| 100M | 0.081s | 1.343s | N/A | N/A |
XY's render time remains nearly flat across four orders of magnitude (0.071s to 0.081s) when using density surfaces. Even without density aggregation (density=False), XY rendered 100M markers in 1.34s.
Resident Memory Usage
XY consistently maintains a lower Python-side memory footprint. At 100M points, XY uses 2.58 GiB of resident memory, whereas the density=False configuration uses 5.26 GiB. In comparison, Matplotlib and Plotly failed to render the 100M point dataset in the tested environment.
API and Integration
XY provides a flexible API that caters to both declarative workflows and those familiar with traditional plotting libraries.
Matplotlib Compatibility
XY includes a xy.pyplot module that allows users to migrate from Matplotlib by changing the import statement while keeping much of their existing plotting code. A compatibility guide is provided for unsupported functionality.
Customization and Styling
Charts can be customized using Python, CSS, or Tailwind CSS. Users can control:
- Marks: Color, size, opacity, symbols, gradients, and colormaps.
- Guides: Axes, ticks, grids, annotations, legends, and tooltips.
- Interaction: Pan, zoom, hover, selections, and linked charts.
- Layout: Layers, facets, responsive dimensions, and themes.
Reflex Integration
Through the reflex-xy adapter, XY charts can be embedded into Reflex web applications as native components without requiring iframes or separate chart services.
Roadmap and Future Capabilities
XY is currently in alpha. The development roadmap prioritizes broad 2D coverage before expanding into geographic, 3D, and volume visualizations. Upcoming features include:
- Categorical Distributions: Strip, swarm, beeswarm, boxen, and rug plots.
- Regression Diagnostics: Trendlines, residuals, QQ, and PP plots.
- Scatter Matrix: SPLOM, pair grids, and marginal histograms.
- Financial Charts: Candlestick/OHLC and overlays like SMA, VWAP, and Bollinger bands.
- Advanced Visuals: Treemaps, sunbursts, radar/polar plots, and 3D/volume surfaces and meshes.
Community Insights
While the library has been praised for its implementation in Rust and its ability to handle massive datasets, some users have raised technical considerations regarding the utility of GPU acceleration for standard dashboards. One user noted:
"Once a chart is dense enough for rendering to become the bottleneck, it normally is already be too crowded to be meaningful."
However, others highlighted the value of the "out-of-core" rendering capability, which allows XY to handle datasets like the entirety of OpenStreetMap (over 10 billion nodes) with sub-second pan and zoom performance.