Wonderful demonstration. I can't help but wonder--as someone who has flirted with R but certainly not committed--how much time and practice it takes to acquire decent fluency with these half-magical incantations to become productive.
Not that long. The trick is to really understand what each clause is doing. It's easy to just find some code on the Web for a graph similar to what you want and tweak it for your data, and I did that myself in the beginning, but then they will remain "half-magical incantations" as you put it. The thing about ggplot is nothing is there arbitrarily -- it is really describing how the plot is put together.
The other thing is that the 'gg' in ggplot2 is the Grammar of Graphics, which describes a high-level grammar for composing visualizations. Having an underlying grammar makes it possible for the syntax to have logical consistency, where once you learn how it works, you can incorporate and generalize simply. (aside, I used to use ggplot2 but I switched to working in python, and I miss ggplot2 so, so much).
The syntax being shown here demonstrates an incremental way of layering on the components of the final visualization, which shows the power of the underlying grammar of graphics.
It depends on what you want to do.
ggplot2 is what I would describe as broad but not deep - you can access 90% of the functionality in a relatively short time.
The main thing is that ggplot2 has been around for a long time, is developed by people that care a lot about R, and there is pretty much an answer to any question you may have on stackoverflow.
ggplot2 also have excellent defaults. I'm really in Visualizations but I'm from the Python world. I had to teach a class using ggllot2 and was really impressed. You can easily make excellent graphs.
This is ggplot. It's not a good example of what it's like to use R in general. I sorely wish there was a well-maintained ggplot for Python because the library is excellent but the language is terrible.
The tidyverse and data.table universes are two very comprehensive sets of packages that kind of offer a replacement to the base R syntax, and they are pretty nice languages.
BBC internally created a cookbook for the same purpose. https://bbc.github.io/rcookbook/ I think it's okay that if someone's fluent in R and yet don't know how to update scales in ggplot.
This is a great demonstration and shows the bit that finally clicked with me. When you learn to wield these tools you'll be considered a wizard by many when you're able to make beautiful plots in seconds.
Bokeh and Plotly produce dynamic, javascript based visualizations. ggplot is for static images, which matplotlib is the obvious counterpart in Python. There are notable packages built on top of matplotlib including seaborn and plotnine.
I've been testing out porting a bunch of analyses from R to python, and it has been very easy to swap in for ggplot2. The biggest downside I can see is that with ggplot2 it's easy to convert to interactive using plotly (but there isn't that kind of support for plotnine yet).
Very nice. I would love some kind of plugin for Rstudio that let you "play" through an arbitrary ggplot like this to help understand how charts are built.
I was thinking more like an automatic way to step through each subsequent "+"'d function rather than having to comment/uncomment repeatedly to isolate what each layer does.
ggplot2's ultra terse, beautiful charts really beat out the competition. I do wish the api's were _less compact_ and more naturally explorable right out of the ide. R as a whole suffers these traits imho. I hope ggplot is ported to the RoW, ideally a typed language or runtime
27 comments
[ 3.2 ms ] story [ 66.5 ms ] threadThe syntax being shown here demonstrates an incremental way of layering on the components of the final visualization, which shows the power of the underlying grammar of graphics.
The main thing is that ggplot2 has been around for a long time, is developed by people that care a lot about R, and there is pretty much an answer to any question you may have on stackoverflow.
It's mentioned on slide 6.
love to see this for other language and plotting
It is fabulous. I use it regularly. https://seaborn.pydata.org/
* is a port of ggplot2 to python
* has a very active maintainer
I've been testing out porting a bunch of analyses from R to python, and it has been very easy to swap in for ggplot2. The biggest downside I can see is that with ggplot2 it's easy to convert to interactive using plotly (but there isn't that kind of support for plotnine yet).
https://github.com/has2k1/plotnine