Live data from Hacker News

Plotnine

plotnine.org

11–20 of 83 posts

Re: Plotnine

#11
post #5

`from plotnine import *` ... I love the idea of a new python plotting library, but why is this anti-pattern so common with plotting libs?

Because most of the time this will be used is not part of a software development project but rather producing publication plots in a script or plots in a notebook. Not what you would want to do when incorporating it into a web app.

Re: Plotnine

#12
post #5

`from plotnine import *` ... I love the idea of a new python plotting library, but why is this anti-pattern so common with plotting libs?

While it’s generally considered to be bad practice to import everything into the global namespace, I think it’s fine to do this in an ad-hoc environment such as a notebook as it makes using the many functions plotnine provides more convenient. An additional advantage is that the resulting code more closely resembles the original ggplot2 code. Alternatively, it’s quite common to `import plotnine as p9` and prefix every function with `p9`.

Disclaimer: I made the plotnine homepage and cheatsheet.

Re: Plotnine

#16
post #9

And it comes with tidyverse-like cheatsheet[1] that I confused with ggplot2 when first discovered plotnine [1]: https://github.com/rstudio/cheatsheets/blob/main/plotnine.pd...

Sorry for the confusion. Though, it is a mango tree in a mango garden! The continued development and maintenance of plotnine is supported by Posit, PBC, the same company behind the Tidyverse.

Disclaimer: I am the author.

Re: Plotnine

#17

Back when I did a lot of data stuff I used ggplot in R because it seemed to be popular, but I was just copy/pasting examples. Then one day I finally started to "get it" and actually read the manual. Learning the grammar of graphics was like a super power. I got to the point I could open pretty much anything people sent me and visualise it in a matter of seconds. Although I've used Python professionally a lot more tha…

[flagged]

Re: Plotnine

#18
post #2

Using operator overloading of "+" to configure the plot is... a choice.

It is! And that's kinda the point.

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

Re: Plotnine

#19
Nice one. I'm aware of plotnine because ggplot is more intuitive IMHO than say matplotlib.

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!

Re: Plotnine

#20
post #2

Using operator overloading of "+" to configure the plot is... a choice.

It is! And that's kinda the point. 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 familia…

And a side note, R actually includes a pipe operator (as in Unix `|`), and said if they'd know about it at the time, they would have never used the `+` operator
Post reply on HN