๐ Hi!
Those days Iโm diving deep into the world of R and Python for data visualization as I am improving the graph galleries.
While both languages are incredibly robust, one thing stands out IMO:
R has a treasure trove of packages specifically designed for dataviz, whereas Python mostly leans on matplotlib tweaks.
๐ A Sea of Choices
As of now, CRAN boasts a whopping 19,805 packages.
That's a lot to sift through!
Even as someone who spends hours exploring R for projects like the R Graph Gallery and data-to-viz.com, I've only scratched the surface.
So, I took to Twitter to ask: what are your go-to R packages for data visualization? ๐ค
I received 31 responses, which, granted, is a tiny sample of the R community.
So this is not real science of course but I think I am right pointing the following as the most popular R packages for dataviz:
1๏ธโฃ ggplot2 & the tidyverse
๐ github: link | โญ๏ธ stars: 6.1k | โ๏ธ author: Hadley Wickham et al.
Not surprisingly, these were the top picks. It is now the gold standard for data analysis in R.
ggplot2 is all about creating stunning and complex plots with ease, while tidyverse is a collection of R packages designed for data science.
This is how building a scatterplot looks like in ggplot2:
Resulting in the following figure. Neat, isnโt it?
2๏ธโฃ patchwork
๐ github: link | โญ๏ธ stars: 2.3k | โ๏ธ author: thomasp85
This package lets you combine multiple ggplot2 plots into one visual masterpiece.
It is a game-changer for anyone who's struggled with the often cumbersome task of combining plots.
It's no wonder it gained rapid adoptionโit solves a very specific but widely-experienced pain point, making it easier than ever to create composite visuals.
3๏ธโฃ Ggiraph, 4๏ธโฃ Plotly, and 5๏ธโฃ Shiny
๐ github: link | โญ๏ธ stars: 701 | โ๏ธ author: David Gohel
๐ github: link | โญ๏ธ stars: 2.4k | โ๏ธ author: Plotly
๐ github: link | โญ๏ธ stars: 5.1k | โ๏ธ author: RStudio
These packages are leading the charge in the growing trend of interactive data visualization within the R community.
ggiraph adds interactivity to ggplot2 graphics, allowing users to hover over or click on elements for more information.
Plotly is another library that can create interactive plots with minimal code, and it integrates seamlessly with R. (Iโm in love with the ggplotly() function btw โค๏ธ)
Shiny takes it a step further by enabling the creation of interactive web apps for data visualization and analysis.
Together, these packages underscore the increasing importance and ease of building interactive data experiences in R.
If you curious, try the following code to see the magick!
6๏ธโฃ ggtext
๐ github: link | โญ๏ธ stars: 614 | โ๏ธ author: wilkelab
This one popped up 5 times and I did not even know it! ๐ณ
ggtext provides simple Markdown and HTML rendering for ggplot2. It makes it much easier to add some proper annotations:
But there are so many more ๐!
If you're new to R, these 6 packages are a great starting point.
For the seasoned R users among us, this result is not earth-shattering though.
But the tweet responses also led me to some hidden gems ๐ฅ. I learnt about things like rayshader, ggbeeswarm, ggpubr and so many others.
Curated list coming ๐โโ๏ธ
To help you (and me!) navigate this landscape, I've started a curated list on the R Graph Gallery.
This list is growing and changing as I am speaking. Packages will be added progressively based on three criteria: GitHub stars, download number, and my personal taste ๐.
But more importantly, I would love to hear if you have a favorite R package that you think deserves a spot on the list! โค๏ธ๐
Thanks and have a wonderful week!
Yan
Note: In the JavaScript world, we have the State of JS , an annual survey of the JavaScript ecosystem. Should we start a State of R at some point? ๐ค
Thanks for this Yan!