Fastplotlib: GPU-accelerated, fast, and interactive plotting library

by rossanton 3/11/25, 4:33 PMwith 179 comments
by CreRecombinaseon 3/11/25, 5:23 PM

Every two weeks or so I peruse github looking for something like this and I have to say this looks really promising. In statistical genetics we make really big scatterplots called Manhattan plots https://en.wikipedia.org/wiki/Manhattan_plot and we have to use all this highly specialized software to visualize at different scales (for a sense of what this looks like: https://my.locuszoom.org/gwas/236887/). Excited to try this out

by jarpinehon 3/12/25, 1:11 PM

This looks very promising. I'll have to think my visualization cases against new possibilities this enables.

I have been intermittently following Rerun, a "robotics-style data visualization" app [1]. Their architecture bears certain similarities [2]. Wgpu in both, egui and imgui, Rust with Python. Rerun's stack does compile to WASM and works in browser. Use cases seem different, but somewhat the same. I don't do scientific nor robotic stuff at all, so no opinions on feasibility of either...

[1] https://rerun.io [2] https://github.com/rerun-io/rerun/blob/main/ARCHITECTURE.md

by dclon 3/12/25, 4:57 AM

I always thought it was interesting that my modern CPU takes ages to plot 100,000 or so points in R or Python (ggplot2, seaborn, plotnine, etc) and yet somehow my 486DX 50Mhz could pump out all those pixels to play Doom interactively and smoothly.

by zoogenyon 3/11/25, 11:11 PM

> powered by WGPU, a cross-platform graphics API that targets Vulkan (Linux), Metal (Mac), and DX12 (Windows).

The fact that they are using WGPU, which appears to be a Python native implementation of WebGPU, suggests there is an interesting possible extended case. As a few other comments suggest, if one knows that the data is available on a machine in a cluster rather than on the local machine of a user, it might make sense to start up a server, expose a port and pass along the data over http to be rendered in a browser. That would make it shareable across the lab. The limit would be the data bandwidth over http (e.g. for the 3 million point case) but it seems like for simpler cases it would be very useful.

That would lead to an interesting exercise of defining a protocol for transferring plot points over http in such a way they could be handed over to a the browser WebGPU interface efficiently. Perhaps even a more efficient representation is possible with some pre-processing on the server side?

by Vipitison 3/11/25, 10:04 PM

I have watched recordings of your recent representation and decided to finally give it a try last week. My goal is to create some interactive network visualizations - like letting you click/box select nodes and edges to highlight subgraphs which sounds possible with the callbacks and selectors.

Haven't had the time to get very far yet, but will gladly contribute an example once I figure something out. Some of the ideas I want to eventually get to is to render shadertoys(interactively?) into a fpl subplot (haven't looked at the code at all, but might be doable), eventually run those interactively in the browser and do the network layout on the GPU with compute shaders (out of scope for fpl).

by crazygringoon 3/11/25, 7:30 PM

Sounds really compelling.

But it doesn't seem to answer how it works in Jupyter notebooks, or if it does at all. Is the GPU acceleration done "client-side" (JavaScript?) or "server-side" (in the kernel?) or is there an option for both?

Because I've used supposedly fast visualization libraries in Google Colab before, but instead of updating at 30 fps, it takes 2 seconds to update after a click, because after the new image is rendered it has to be transmitted via the Jupyter connector and network and that can turn out to be really slow.

by theLiminatoron 3/11/25, 5:19 PM

Do you have any numbers for the rough number of datapoints that can be handled? I'm curious if this enables plotting many millions of datapoints in a scatterplot for example.

by wodenokotoon 3/12/25, 5:02 AM

How is it compared to HoloViz?[1]

I followed one of their online workshops, and it feels really powerful, although it is a bit confusing which part of it does what (it's basically 6 or 7 projects put together under an umbrella)

[1] https://holoviz.org/

by juliusbkon 3/11/25, 8:19 PM

This looks super cool! Looking forward to trying it.

I think a killer feature of these gpu-plotting libraries would be if they could take torch/jax cuda arrays directly and not require a (slow) transfer over cpu.

by 7speteron 3/11/25, 9:55 PM

I’m not making neuroscience visualizations. I’m working with rather line graphs and would like to animate based on ~10000 points. I’m looking to convert these visuals to video for youtube, in hd and at 60fps using the HEVC/h.265 codec. I took a quick look at the documentation to see if this is possible and I didn’t see anything. Are or will this sort of rendering be supported?

I previously tried this on matplotlib and it took 20-30 minutes to make a single rendering because matplotlib only uses a single core on a cpu and doesn’t support gpu acceleration. I also tried Man im, but I couldn’t get an actual video file, and opengl seems to be a bit complicated to work with (I went and worked on other things though I should ask around about the video file output). Anyway, I’m excited about the prospect of a gpu accelerated dataviz tool that utilizes Vulkan, and I hope this library can cover my usecase.

by paddy_mon 3/11/25, 5:07 PM

Really nice post introducing your library.

When would you reach for a different library instead of fastplotlib?

How does this deal with really large datasets? Are you doing any type of downsampling?

How does this work with pandas? I didn't see it as a requirement in setup.py

Does this work in Jupyter notebooks? What about marimo?

by lagrange77on 3/11/25, 7:54 PM

Nice, i'd be interested to know which method for drawing lines (which is hard [0]) it uses.

[0] https://mattdesl.svbtle.com/drawing-lines-is-hard

by carabineron 3/11/25, 5:08 PM

GPU all the things! GPU-accelerated Tableau would be incredible.

by pamaon 3/11/25, 5:16 PM

I know 3D is in the roadmap. Once the basic functionality is in place, it would be great to also consider integrating molecular visualization or at least provide enough fast primitives to simplify the integration of molecular visualization tools with this library.

by dorighton 3/12/25, 12:03 AM

Sometimes I wish these plotting libraries were more portable beyond Python only. I was looking for something similar for Ruby just a while ago but the install instructions seemed out of date and unsupported on Windows.

by anthkon 3/12/25, 12:14 PM

Here people using tons of GB and VRAM for tasks I just used awk and gnuplot on really underpowered machines. Such as the guys who parsed GB sized texts files ('big data', you know) containing IPs and Cloudflare hosts (due to LaLiga scandal blocking whole CF IP's because some of them they were user for soccer TV broadcasting piracy) by using CUDA and some bullshit, when the same tasks could be done with mawk in less than an hour.

by enriqutoon 3/11/25, 10:30 PM

That would be preposterous if it wasn't so hilariously false:

> These days, having a GPU is practically a prerequisite to doing science, and visualization is no exception.

It becomes really funny when they go on to this, as if it was a big deal:

> Depicted below is an example of plotting 3 million points

Anybody who has ever used C or fortran knows that a modern CPU can easily churn through "3 million points" at more than 30 frames per second, using just one thread. It's not a particularly impressive feat, three million points is the size of a mid-resolution picture, and you can zoom-in and out those trivially in real-time using a CPU (and you could do that 20 years ago, as well). Maybe the stated slowness of fastplotlib comes from the unholy mix of rust and python?

Now, besides this rant, I think that fastplotlib is fantastic and, as an (unwilling) user of Python for data science, it's a godsend. It's just that the hype of that website sits wrong in me. All the demos show things that could be done much easier and just as fast when I was a teenager. The big feat, and a really big one at that, is that you can access this sort of performance from python. I love it, in a way, because it makes my life easier now; but it feels like a self-inflicted problem was solved in a very roundabout way.

by klaussilveiraon 3/11/25, 6:12 PM

Very cool to see imgui empowering so many different things.

by vibraniumon 3/11/25, 10:21 PM

I’m often working with a windows desktop and a remote Linux box on which I have my data & code. I’d like to plot “locally” on my desktop workstation from the remote host. This usually either means using X11 (slow) or some sort of web-based library like plotly. Does fastplotlib offer any easy solution here?

by roteron 3/11/25, 7:28 PM

Very interesting and promising package.

I especially like that there is a PyQt interface which might provide an alternative to another great package: pyqtgraph[0].

[0] https://github.com/pyqtgraph/pyqtgraph

by abdullahkhalidson 3/11/25, 6:00 PM

Is it possible to put the interactive plots on your website? Or is this a Jupyter notebook only tool.

by trostafton 3/11/25, 9:35 PM

Looks very interesting for interactive visualization. I like the animation interface. Also love imgui, glad to see it here. I wish I had better plotting tools for publication quality images (though, honestly I'm pretty happy with matplotlib).

by meiselon 3/11/25, 6:06 PM

One of the big bottlenecks of plotting libraries is simply the time it takes to import the library. I’ve seen matplotlib being slow to import, and in Julia they even have a “time to first plot” metric. I’d be curious to see how this library compares.

by insane_dreameron 3/12/25, 12:10 PM

Looks great--and meets a significant need. I see you have meshes on the roadmap--very much looking forward to testing that for real-time cortex mapping once available. Kudos.

by goobooon 3/11/25, 7:30 PM

Yeah, many browsers have webgpu turned off by default, So you're stuck with wasm (wasm Simd if you're lucky)

Hopefully both are implemented.

by _aleph2c_on 3/11/25, 10:32 PM

https://archive.md/G3wj6

by asterix_panoon 3/12/25, 6:16 AM

Looks very interesting. Does it allow to plot lines of varying thickness?

by vegabookon 3/12/25, 9:27 AM

Syntax looks matplotlib-ish so we’re going back to 2003

by MortyWaveson 3/11/25, 10:00 PM

Another tool that requires precise control over memory layout, bandwidth, performance… using Python.

by asanghaon 3/11/25, 5:00 PM

>sine_wave.colors[::3] = "red"

I never knew I needed this until now

by sfpotteron 3/11/25, 5:05 PM

Very cool effort. That said, and it's probably because of the kind of work that I do, but I have almost never found the four challenges to be any kind of a problem for me. Although I do think there is some kind of contradiction there. Plotting (exploratory data analyis ("EDA"), really) is all about distilling key insights and finding features hidden in data. But you have to some kind of intuition about where the needle in the haystack is. IME, throwing up a ton of plots and being able to scrub around in them never seems to provide much insight. It's also very fast---usually the feedback loop is like "make a plot, go away and think about it for an hour, decide what plot I need to make next, repeat". If there is too much data on the screen it defeats the point of EDA a little bit.

For me, matplotlib still reigns supreme. Rather than a fancy new visualization framework, I'd love for matplotlib to just be improved (admittedly, fastplotlib covers a different set of needs than what matplotlib does... but the author named it what they named it, so they have invited comparison. ;-) ).

Two things for me at least that would go a long way:

1) Better 3D plotting. It sucks, it's slow, it's basically unusable, although I do like how it looks most of the time. I mainly use PyVista now but it sure would be nice to have the power of a PyVista in a matplotlib subplot with a style consistent with the rest of matplotlib.

2) Some kind of WYSIWYG editor that will let you propagate changes back into your plot easily. It's faster and easier to adjust your plot layout visually rather than in code. I'd love to be able to make a plot, open up a WYSIWYG editor, lay things out a bit, and have those changes propagate back to code so that I can save it for all time.

(If these features already exist I'll be ecstatic ;-) )

by rossanton 3/11/25, 6:38 PM

Shameless plug: I'm actively working on a similar project, Datoviz [1], a C/C++ library with thin Python bindings (ctypes). It supports both 2D and 3D but is currently less mature and feature-complete than fastplotlib. It is also lower level (high-level capabilities will soon be provided by VisPy 2.0 which will be built on top of Datoviz, among other possible backends).

My focus is primarily on raw performance, visual quality, and scalability for large datasets—millions, tens of millions of points, or even more.

[1] https://datoviz.org/

by 749402826on 3/11/25, 6:12 PM

"Fast" is a bold claim, given the complete lack of benchmarks and the fact that it's written entirely in Python...

by ZeroCool2uon 3/11/25, 4:57 PM

Seems like a nice library, but I have a hard time seeing myself using it over plotly. The plotly express API is just so simple and easy. For example, here's the docs for the histogram plot: https://plotly.com/python/histograms/

This code gives you a fully interactive, and performant, histogram plot:

```python

import plotly.express as px df = px.data.tips() fig = px.histogram(df, x="total_bill") fig.show()

```

by Starlord2048on 3/11/25, 6:12 PM

[flagged]

by qoezon 3/11/25, 7:22 PM

[flagged]