... I love the idea of a new python plotting library, but why is this anti-pattern so common with plotting libs?
Disclaimer: I made the plotnine homepage and cheatsheet.
Whilst it's still not yet at 1.0.0, it's not that new: the first (0.1.0) release was in 2017: https://pypi.org/project/plotnine/#history
Like others mention, this is inspired by ggplot2, a Grammar of Graphics library. The whole idea is graphics are composed by adding "layers", not like layers on a canvas, but like pouring paint into a pot, then the library understands the content and paints it to the canvas.
Layers might be pure data, geometry (lines, points, ...), annotations, styles, axis, etc.
When you get familiar with it, it's much more natural way of describing plots, better composition and easier exploration
[1]: https://github.com/rstudio/cheatsheets/blob/main/plotnine.pd...
Disclaimer: I am the author.
2 things that would be awesome are interactive plots (hover + text box) and chlorpleth (tiled map) plots.
On closer look you have already nailed the latter!
Disclaimer: I am the author of plotnine.
(Both has2k1 and I work for Posit, which supports plotnine work, but authoring its guide was mostly an act of passion for me :)
The R language is just so much more beautiful than Python, in its full lispy goodness, with lazy evaluation.
It doesn't matter quite as much now that I have LLMs write a good chunk of the plotting code. But the LLM python plotting code is easily 5x-10x as many lines as a hand-crafted R plot, making it slower and harder to grok than R.
You can get a sneak peek by installing the pre-release:
pip install --pre plotnine
Details here: https://github.com/has2k1/plotnine/issues/1031
Disclaimer: I'm the author.
In almost any situation you either want to talk about the actual distribution (in which case plotting the distribution on one side of the line arranged horizontally is significantly superior to plotting it vertically on both sides of the line for some reason as a violin plot does[1]) or you want to talk about the quartiles etc in which case a boxplot is better.
A violin plot tries to do both and as a result does them both badly.
Extended anti-violin plot rant here https://www.youtube.com/watch?v=_0QMKFzW9fw
[1] I remember in one meeting before I knew better, producing some violin plots and putting them on a slide and I knew I had gone wrong when that slide came up and everyone in the room had this confused expression on their faces and was leaning their head over to the side to try to see the distribution better. When your visualization produces obvious confusion like that, you can be completely certain it has failed.
https://williamcotton.github.io/algraf
It pairs well with a related data translation DSL:
https://williamcotton.github.io/pdl
And you can see the two working together here:
https://williamcotton.github.io/datafarm-studio
There's LSPs for both, LSP clients for VS Code, and even language diagnostics for standalone Monaco editors in the browser.
Of note is that the same language diagnostics are exposed via the WASM as via the LSP interface allowing for the same friendly red squiggles to look and work the same in both your browser with Monaco and your editor with the LSP!
You get so much more information in plots using bokeh (or I assume plotly).
Tooltips, zooming, interaction.
And the LLM helps a lot when the plot is a bit more complex.
Plotnine: Grammar of Graphics for Python (2019) - https://news.ycombinator.com/item?id=25948840 - Jan 2021 (37 comments)
Plotnine: A grammar of graphics for Python - https://news.ycombinator.com/item?id=14430447 - May 2017 (38 comments)
(Disclosure: I'm at Posit, which supports plotnine.)
Semi related -- I made a little d3.js AI wrapper that works pretty well for making quick charts -- https://prompt2chart.com/share/e998a3f6-9482-4c18-931f-a4513...; https://prompt2chart.com/;
Although I've used Python professionally a lot more than R, I still felt like R was better at this. Somehow opening files in Python always feels a bit more "heavy". I don't really know why, though.
Altair and Bokeh are also quite good for interactive graphs, but plotnine is so ergonomic.