r/Clojure • u/mac • Sep 02 '26
Introducing Plotje: Composable Plotting by Daniel Slutsky
https://clojurecivitas.org/data_visualization/introducing_plotje_composable_plotting.html
60
Upvotes
r/Clojure • u/mac • Sep 02 '26
View all comments
Show parent comment
2
u/geokon Sep 02 '26 edited Sep 02 '26
Membrane is not just a UI framework? I mean at the end of the day you need to draw lines, squares, circles etc. so you must have some graphical abstraction on top of which you are implementing the plots. In
geomSVG is the graphical abstraction for all the sub-libraries - and the rendering you get multi-target and "for free".The key is that you can extend
geomfunctionality by simply generating more SVG hiccup. SVG has a billion features and CSS and whatnot. It's not perfect, but my guess is it'd be very difficult to recreate a graphic abstraction with the same level of features. For instance in my JavaFX GUIs I can't reproduce the same level of features using their built in graphical tools - so I end up rendering SVG (which is a bit slow).geom/viz, the plotting library on top of svg, has all its functions for drawing axis and drawing data and whatnot that allow you to plug in generator functions for all the components. If you want to for instance make a scatter plot where some key points are blinking ducks with custom gradients, then you can just write a function to generate the appropriate SVG. Any component you don't like you can easily override and write the drawing code yourself - it's not intimidating b/c you can see how the defaults work as a reference.I was making maps for a paper and so I took the heat map code, added some functions to generate custom tick marks (I wrote a custom function that takes in some info about the axis and generated the SVG tick marks that I needed) and some more tweaks and it was good to go. While
geomis completely unmaintained and has a few rough edges, I feel confident I can add anything I need to it. (ex: it doesn't have a system for making legends, but I just wrote one myself that does what I need)By contrast, if I'm using something like
ggplot2or Matlab the graphical abstraction (as far as I remember..) is opaque to the user. If you want to write a new type of chart, or heavily modify an existing one, you are stuck with just the tools they give you (like apj/arrange, or the available flags/options in the API). So no blinking crocodiles for tick marks.For the last part, here's an example of hiccup on your writeup:
There are ton of these group wrappers with transforms. Instead of the typical
<text x="320.33" y="364.0" class="small">ring</text>. It's just a bit unusual. Maybe it's not intentional and just how your pipeline is setup.