Live data from Hacker News

Plotnine

plotnine.org

61–70 of 83 posts

Re: Plotnine

#61
post #51

Plotnine has been great in my usage, but I see violin plots on the front page. Just say no to violin plots. 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 t…

Violin plots have an interesting reputation ( https://xkcd.com/1967/ , https://www.reddit.com/r/labrats/comments/91ex4u/is_it_just_... , https://jabde.com/2022/12/22/banned-violin-plots/ ). For showing distributions, I much prefer strip plots ( https://seaborn.pydata.org/generated/seaborn.stripplot.html ), perhaps with opacity, or swarm plots ( https://seaborn.pydata.org/generated/seaborn.swarmplot.html ) - no averag…

Another alternative is raincloud plot (depending on data).

Re: Plotnine

#62
post #48

I've always liked the ggplot2 and the Grammar of Graphics approach to plotting so much so that I wrote my own DSL based on it - it is standalone, written in Rust, has WASM bindings (as you can see on the website) and more: 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.gi…

A year ago, added R to the pipeline (with multiple complications) just to use ggplot2 - even though Python was the main tech. https://quesma.com/blog/sandboxing-ai-generated-code-why-we-... Good, that ggplot2 can run inside in WASM, vide https://github.com/QuesmaOrg/webr-ggplot-playground

A big part of the motivation was that something like this...

  $ which ggplot
  ggplot () {
          if [[ "$1" == "-f" ]]
          then
                  shift
                  rush run --library tidyverse "$(cat "$1")" -
          else
                  rush run --library tidyverse "$@" -
          fi
  }

  $ echo "one,two,three\n1,2,3\n4,5,6\n,7,8,9" | ggplot 'ggplot(df, aes(one, two)) + geom_col() + theme_minimal()' | imgcat
...is just very slow. Booting R just to run ggplot2 was not cutting it compared to a custom DSL written in Rust!

BTW, that "R on the command line" tool was inspired by:

https://datascienceatthecommandline.com

Re: Plotnine

#63

Is the selling point for this vs e.g. Plotly just the ggplot style semantics?

The selling point is the grammar of graphics. See Wilkinson on the subject.

Re: Plotnine

#64
post #43

matplotlib is what most folks reach for by default, but I'd argue that's habit and popularity talking, not a real fit advantage. For a lot of plotting work, the grammar-of-graphics libraries — Altair, plotnine — may be the better tool for many people (and Agents); they just don't have the muscle memory behind them. (Disclosure: I'm at Posit, which supports plotnine.)

What would you say are the benefits of the grammar-of-graphics approach? I've been working with plotting for more than a decade now and have never heard of it. Right now I'm looking through the gallery and can't really grasp what makes this approach better than the one in matplotlib. PS. It took someone in the comments writing "import plotnine as p9" for me to understand it isn't plotLine.

> What would you say are the benefits of the grammar-of-graphics approach?

When a mathematical formalism exists, just use that. Other approaches just reinvent the wheel on an ad-hoc/piecemeal basis and end up making all sorts of unnecessary compromises.

Re: Plotnine

#65
It is great, but I have completely given up non-interactive plots since a while.

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.

Re: Plotnine

#66

Plotnine has been great in my usage, but I see violin plots on the front page. Just say no to violin plots. 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 t…

You couldn't pay me enough to be this opinionated about something so banal.

Re: Plotnine

#67
If this was for JS and not Python I would be all over it for the upcoming NFL/NBA seasons and my stat visualizations

Re: Plotnine

#68
post #49

Earlier quoted context omitted.

What would you say are the benefits of the grammar-of-graphics approach? I've been working with plotting for more than a decade now and have never heard of it. Right now I'm looking through the gallery and can't really grasp what makes this approach better than the one in matplotlib. PS. It took someone in the comments writing "import plotnine as p9" for me to understand it isn't plotLine.

It has to do with the structure of the information/inputs. Its more a DSL with a structure rather than a jumble of API arguments. So first few times out it may take some getting used to, but as that structure becomes clear it becomes more intuitive. Thats also why even with way more matplotlib examples in the world, LLM agents do better "guessing" how to use plotnine... or at least it was that way a few months ago wh…

[flagged]
Post reply on HN