[HN Gopher] Plotnine: Grammar of Graphics for Python
___________________________________________________________________
Plotnine: Grammar of Graphics for Python
Author : EntICOnc
Score : 53 points
Date : 2021-01-28 20:40 UTC (2 hours ago)
(HTM) web link (datascienceworkshops.com)
(TXT) w3m dump (datascienceworkshops.com)
| closed wrote:
| In case anyone is wondering what the big deal is with ggplot /
| plotnine, I record myself doing hour long data analyses in python
| with it!
|
| I've noticed that a lot of bootcamp grads can use matplotlib to
| do very simple plots, but when it comes to iterating on a data
| analysis (trying different plots, facetting on variables, etc..),
| they get tripped up quickly.
|
| I've been trying to use a port of dplyr I'm working on (siuba)
| and plotnine to show what on-the-fly analyses might look like.
| Can't speak highly enough of plotnine!
|
| https://youtu.be/z6xNKZZMWgU
| abhisuri97 wrote:
| I've had to learn R for some Epi classes this semester and,
| coming from doing figures/stat analysis in python, it really is a
| breath of fresh air. Imo, The R ecosystem for stats and figure-
| making just has much better "defaults" than matplotlib. That
| being said, I have been incredibly frustrated with R error
| messages and some syntactical things about the language, so I'm
| super happy to hear that plotnine exists.
| GizmoSwan wrote:
| Wow. Very useful.
|
| Keeping a bookmark for when I need it and I will use this
| sometime in future I am sure.
| fvfvefdvrhhtgfv wrote:
| 8888
| fvfvefdvrhhtgfv wrote:
| 55
| binarymax wrote:
| My colleague who is a pro at R gave us some internal training on
| using this in Python. Never going back to Matplotlib again!
| simlan wrote:
| First time i hear about this. It is definitely pretty but i can
| not wrap my head around the syntax... It feels wrong. But i am a
| long time matplotlib user so that should be no surprise.
| superbcarrot wrote:
| Some basic building blocks for it:
|
| - the data source is always in a dataframe
|
| - you can add one or more geometries like points or lines to a
| plot
|
| - properties of geoms can be either hardcoded or (more often)
| mapped to a variable from the dataframe. That's what the
| "mapping=aes()" syntax does.
|
| The last part is really the main thing you have to worry about
| building visualisations - which variable from the dataset to
| map to which element of the plot. And yes, it still looks a bit
| weird to read R syntax in a Python script.
| flobosg wrote:
| Yeah, the Grammar of Graphics syntax can feel a bit awkward at
| first, but once it clicks it makes a lot of sense.
| khr wrote:
| I found a previous HN submission very helpful:
| https://evamaerey.github.io/ggplot_flipbook/ggplot_flipbook_...
|
| The author builds up plots step by step, showing the changes to
| the plot along the way. It's really great at showing what each
| element contributes to the final plot.
| EForEndeavour wrote:
| This tutorial is excellent, and skimming it was worth it to me
| just for the discovery of https://github.com/Phlya/adjustText!
|
| Also, an unfortunate namespace wart is that there's a python
| package called ggpy that seems to have been abandoned since 2016:
| https://github.com/yhat/ggpy
|
| "plotnine" being the de facto python equivalent of ggplot2 is not
| obvious at all, but I'll take it :)
| frakt0x90 wrote:
| I use this daily and love it. I used to use R just for EDA and
| visualization and Python for the rest but plotnine hanged that
| for me so I can do everything in one language. So much better
| than Matplotlib IMO.
| domoritz wrote:
| As a related tool, there is Altair (https://altair-
| viz.github.io/), which also implements the Grammar of Graphics as
| well as a Grammar of Interaction.
| vladsanchez wrote:
| You beat me here! I was surprised that I didn't find "Altair"
| in the source article. Thanks for posting.
___________________________________________________________________
(page generated 2021-01-28 23:00 UTC)