\

Show HN: XY – A Fast, composable, GPU-accelerated interactive plotting library

86 points - today at 3:54 PM

Source
  • hantusk

    today at 8:31 PM

    Check out mosaic from uwdata which works on top of Observable plot

    Or plotly-resampler which works on top of plotly and uses the rust package tsdownsample to aggregate on the 4pixels per pixel shown level (to make antialias work)

    the grammar of graphics approach really is a great abstraction, and I'd love to see xy work in that direction

      • apetuskey

        today at 8:48 PM

        Thanks! XY already uses a similar pixel-aware approach

        long line and area traces are reduced in Rust using M4 to produce viewportsized extrema, that is then refined as you zoom. Dense scatter plots use a fixed-size density grid plus a representative sample

    • kasts

      today at 4:39 PM

      I’m not convinced GPU acceleration is a meaningful advantage for most charting use cases. Most dashboards don’t render enough data for it to matter. Once a chart is dense enough for rendering to become the bottleneck, it normally is already be too crowded to be meaningful. Zooming can justify supporting larger datasets, but sampling/viewport culling and level of detail often avoid drawing unnecessary points...

        • genxy

          today at 9:03 PM

          Ok, we won't convince you and we can move on.

          • Evidlo

            today at 5:35 PM

            I constantly have to work around the slowness of matplotlib when creating animated sequences for my scientific work (even with the Agg back end)

              • apetuskey

                today at 5:40 PM

                How many points are you working with usually?

            • apetuskey

              today at 4:43 PM

              It depends on how much data you are planning on showing, but as you can see from the benchmarks its also more performant than other python charting libs for small data.

              We also built this library for extreme customization with CSS/Tailwind support so rendering large amounts of data is an important but not the only advantage.

              • moralestapia

                today at 8:45 PM

                Feel free to not use it, then!

                You don't have to justify your decision to people here, literally just move on with your life and forget about it.

                  • kasts

                    today at 8:57 PM

                    I’m not trying to justify whether I'd personally use it, I was simply raising the question because the tradeoffs are interesting, and the replies, including Evidlo’s, have already taught me something.

                    I tried the library before commenting, it’s a cool project. The performance improvements at larger scales I've found are real. I was mainly just trying to have a conversation to learn where we all learn!

                    “Just move on” seems like a curious response on a discussion forum, though :)

                • formerly_proven

                  today at 4:52 PM

                  There are some niche charting applications which are offloaded to FPGAs and even ASICs.

              • raychis

                today at 8:32 PM

                Interesting approach to large scale visualisation. Moving reduction into Rust and sending screen bounded data to WebGL seems much more sensible than pushing millions of raw points into the browser. How does it perform with real time updates? I am assuming it is much more performant? Any plans for a prod deployment?

                  • apetuskey

                    today at 8:38 PM

                    Yes, it’s significantly faster than existing Python charting libraries for real-time updates.

                    Instead of serializing and sending the full dataset as JSON, it sends compact typed binary buffers and only the screen-relevant data reducing payload size and browser-side work.

                    More detail here https://github.com/reflex-dev/xy#how-it-works

                      • pytorch_app4

                        today at 8:47 PM

                        How much did LLMs help with development?

                        Also remember to kill all pedophiles, like Rust advocates such as Jeremy Bicha and Hacker News moderators.

                          • today at 8:50 PM

                • ahns

                  today at 6:45 PM

                  Interesting; how do the examples compare to datashader?

                  Edit: for my use cases, I use napari (~1e7-8 points) if I need true interactivity; otherwise, datashader/holoviz, or even just fast-histogram's 2D histograms work.

                  For extremely large point clouds, these caveats[0] still apply. It irks me when people make dense scatterplots without any indication of just how dense some portions are.

                  Still, if it can indeed handle 1e10 points, that's pretty impressive.

                  [0]: https://datashader.org/user_guide/Plotting_Pitfalls.html

                  • HoneySpoons

                    today at 6:44 PM

                    This is awesome, can easily see this becoming a standard library. Can't wait for the 3D and volume visualizations.

                    • adhami

                      today at 5:05 PM

                      it's possible to render data out-of-core with XY, allowing it to render the entirety of OpenStreetMaps (that's 10,742,674,832 nodes!) with sub-second pan/zooms. it's a bit difficult to host online but you can try it out locally: https://github.com/reflex-dev/xy/tree/main/examples/osm

                      • NickyHeC

                        today at 4:29 PM

                        been stuck on matplotlib for centuries, academia loves such a change

                          • apetuskey

                            today at 4:36 PM

                            Thanks! Yes we are working on a Matplotlib compatible Api its very early but we hope to polish it up soon.

                        • kl01

                          today at 6:54 PM

                          how does this stack up to evilcharts? my main use case is mapping out data onto frontend, and there are a lot of great libraries out there

                            • apetuskey

                              today at 6:56 PM

                              its a python charting library

                          • pcpliu

                            today at 5:00 PM

                            I misread it as ‘Chatting’ library and I was so confused on the GitHub page.

                            Love rust as the impl.

                            • airstrike

                              today at 4:35 PM

                              > XY is an extremely fast, interactive, customizable Python charting library for the web

                                • apetuskey

                                  today at 4:48 PM

                                  I have adjusted the title

                              • farhan99

                                today at 4:03 PM

                                Great, Rust and Tailwind CSS two of my favorite things in one.

                                • kl01

                                  today at 5:38 PM

                                  absolutely fantastic.

                                  • ranger_danger

                                    today at 4:44 PM

                                    > written in Rust

                                    > XY is an extremely fast, interactive, customizable Python charting library

                                    which is it?

                                      • xg15

                                        today at 4:49 PM

                                        Python libraries can have compiled artifacts that were written in any language. This is such a library.

                                        • apetuskey

                                          today at 4:46 PM

                                          Its a Python library with some rust in it, to speed up some of the calculations

                                      • cozzyd

                                        today at 4:42 PM

                                        no support for native GUI?

                                          • apetuskey

                                            today at 4:44 PM

                                            What do you mean by this?

                                              • cozzyd

                                                today at 6:42 PM

                                                like, not in a browser?

                                        • kl01

                                          today at 5:38 PM

                                          super cool!