Observable Plot: A JavaScript library for exploratory data visualization
observablehq.com
observablehq.com
For this site, we wrote a little Vue component to support server-side rendering for Plot (as part of static site generation at build time). There’s just a little adapter to convert Vue’s hyperscript to the standard DOM API here:
https://github.com/observablehq/plot/blob/main/docs/componen...
The end result is that all the Plot examples are authored simply as fenced js code blocks, but we get server-side rendering so the plots are already rendered when the page loads with no reflow! You can see an example here:
https://github.com/observablehq/plot/blob/33c5560e24aee08cdb...
(For plots that would be too expensive to serialize to inline SVG, we render them client-side-only, and use requestIdleCallback or an IntersectionObserver to defer rendering to avoid jank.)
Add to that, while we were writing the docs, the VitePress team incorporated minisearch for instant search with no dependencies on external services. Huge kudos to Evan You and the VitePress team for building such a great product! It’s a huge boon to the open-source community to make it easier to write beautiful and usable docs.
Oh. And be sure to try dark mode!
If you've looked at Plot in the past you have almost certainly missed a ton of stuff, they're shipping new features constantly. It's worth reviewing the changelog: https://github.com/observablehq/plot/blob/main/CHANGELOG.md
RATH, auto exploratory data analysis: https://github.com/Kanaries/Rath
GraphicWalker, embeddable data exploration component: https://github.com/Kanaries/graphic-walker
They are using vega-lite for now. But there is a limit of building more fancy and customized visualizations. It seems Plot has a more flexible layer based visualization system that can support larger design space.
Is Plot stable enough now to migrate from vega-lite based system to Plot based? Are there any large milestone or roadmap of Plot in future?
We’re working on tooltips now, and interaction next. There’s a PR here with an early sketch and demo video: https://github.com/observablehq/plot/pull/721
I'm not a Vega patriot or anything, just genuinely wondering what I get here.
More generally, our motivations are here: https://observablehq.com/plot/why-plot
What I personally like most about Plot is that it’s purely JavaScript (/ TypeScript); it doesn’t try to be serializable as JSON and portable to Python etc. So whereas Vega-Lite has to have its own expression language (https://vega.github.io/vega/docs/expressions/):
"transform": {
"calculate": [{"field": "b2","expr": "2*datum.b"}],
"filter": "datum.b2 > 60"
},
…in Plot you’d use plain JavaScript: y: d => 2 * d.b,
filter: d => d.b2 > 60
…which I find easier and more powerful. (But I don’t need VL’s portability; others may.)[1] I can hear you screaming WHAT ARE YOU TALKING ABOUT. I should probably enunciate this better. The docs are aerospace, so any graphics or tables or data or ANYTHING has to be source controlled, so the data goes into VCS with the docs, and it can get traced back to a commit, which is passed into a "List of Changes", a "List of Effective Data Modules", and (biggest pain in my ass) change marks in the output. "Prerendered" is a pass that turns the data into a graphic, and then the doc references the graphic. A graph block just points to the data, and the graph is automatic. If it wasn't so controlled, you could just put a passthrough in the asciidoc to the graph server and call it a day - which, honestly, is a much better option, but would require a few Amazon's worth of forms to fill out. And it would probably get rejected because OH MY GERD SERVERS.
Turn on "show graph", then pan the map a bit to start things moving.
It worked fairly well, although I found there were unexpected places where certain combinations of things just weren't possible. You can have a graph of type X, and color things by Y, and in style Z...and XY works, and YZ works, but not XYZ.
(I never did work out how to change the labels for the colors so they aren't "false" and "true" but something more meaningful.)
It was a bit frustrating at times. The documentation tends to be described in terms of examples and snippets, with not enough rigorous reference material that tells you exactly what properties are available and exactly how they work.
That was a year or so ago, so likely it's improved since then.
What are we looking at though? Logs of personal treasure hunt hikes related to https://en.wikipedia.org/wiki/Geohash and https://en.wikipedia.org/wiki/Geocaching?
https://github.com/observablehq/plot/pull/1304
In the meantime, you can do lots of interactive stuff with the SVG that Plot generates. There’s a nice tooltip plugin by Mike Freeman here:
Is it easy to customize charts? It'd be so nice to use this to do a circular/radial tree/node visualization, e.g. something like this: https://truth-and-beauty.net/projects/muesli-ingredient-netw...
One bizarre workaround right now is to abuse the geographic projections: https://observablehq.com/@observablehq/pie-to-donut-chart
In general, you can do a lot of customization, including plugins (though that’s not well-documented yet), so you could make it work… see https://observablehq.com/@fil/radial-transform, https://observablehq.com/@observablehq/plot-radial-line for other approaches to hacking radial stuff into Plot.
You can do Cartesian tree diagrams in Plot, e.g. https://observablehq.com/@observablehq/plot-tree-flare, https://observablehq.com/@observablehq/plot-custom-tree-layo...
If you want to make a chord diagram like that “Müsli Ingredient Network” example, you could try one of these D3 examples: https://observablehq.com/@d3/chord-diagram, https://observablehq.com/@d3/hierarchical-edge-bundling/2
I dug into the documentation a little bit and didn't see much regarding animation. It looks like the word transitions is used as a data transform in the plot API and not as a CSS transition? I'm unsure if there is another keyword to use when searching. I didn't find much about doing any kind of animations with this library, other than that you need to start customizating using D3 API inside the plot calls.
I'm interested in simple animations like "when this chart displays for the first time, start with data at zero, then animate to the final state." Is that possible with plot? I'm not looking for animation across different sets or shapes of data.
Mike Freeman made a helper function that adds that sort of animation (data gradually coming in) using D3 atop Plot: https://observablehq.com/@mkfreeman/plot-animation
You could upvote this incremental rendering issue: https://github.com/observablehq/plot/issues/328
Or this one for adding a “time channel” to do data-driven animation (for which there’s an old draft PR): https://github.com/observablehq/plot/issues/166
My experience in the Python ecosystem a few years back was that for dataviz, there was nothing that approached the polish and power of R’s ggplot2. Does anyone know whether that’s changed?
I just went through a process of evaluating around 7 different libraries and eventually decided on Plotly.
What is the USP of Observable Plot?
Secondly, I simply find the API to be very tastefully built. The Geo API (https://observablehq.com/plot/marks/geo) is a particular highlight. I've used Plot for about 1.5 years for recreational side projects - it has genuinely kept me entertained for many hours in no small part due to its interface design.
I may have a look at the transforms.
I saw the examples for OP and did not see anything challenging Plotly for my use cases.
- rich tooltips (coming soon in Plot)
- interactive pan & zoom
- multiple panels with shared scales? (like for marginal distributions; you can combine with HTML of course, but it’s not easy/built-in in Plot)
Looks similar to Vega or Vega-lite(https://vega.github.io/vega-lite/). Definitely as rich as D3.js but gets the job done for simple visualisations.
You can read more about our chart cell here: https://observablehq.com/@observablehq/chart-cell
And Plot.auto here: https://observablehq.com/plot/marks/auto
React: https://observablehq.com/plot/getting-started#plot-in-react
Vue: https://observablehq.com/plot/getting-started#plot-in-vue
I've been using GNUPlot in drawing chart in emacs. Plot has much better examples and I'd like to try this instead.
We don't have a good KDE built-in yet, but you could upvote https://github.com/observablehq/plot/issues/1469
For simple data visualization with animations, e.g. Flourish is a good option, but it's limited without enterprise access. You can find examples here: https://flourish.studio/examples
So, I really enjoyed Observable's new documentation and tutorials which actually show, not tell how to use the cool examples with your own data.
(Note: I really dislike apps that only have video tutorials. It's hard to follow along and not get bored or lost. Sorry about this rant in advance, and thanks for all the producers who offer clear documentation as text or reasonable guided tours.)