Mastering ggplot2: From Novice to Data Viz Pro

Unleash Your Inner Data Scientist

Author

Tuhin Rana

Published

March 17, 2023

Before We Start

In December 2017, after completing my first year of statistics, I delved into learning R. Having a background in Java, C, and C++ coding since high school, I enjoyed R but found its plots not so appealing and the code a bit tricky. On a quest for something beautiful and user-friendly, I stumbled upon a blog titled Beautiful plotting in R: A ggplot2 cheatsheet by Zev Ross, last updated in January 2016. Intrigued, I decided to follow the tutorial step by step, learning a great deal. As time passed, I tweaked and expanded the codes, adding new chart types and resources.

Realizing that Zev Ross’s blog hadn’t been updated for years, I took the initiative to create my own version, incorporating updates like the amazing {patchwork}, {ggtext}, and {ggforce} packages. I also shared insights on custom fonts, colors, and introduced a variety of R packages for interactive charts. The journey led to a unique tutorial, and now, I’ve decided to make it public, adding even more updates, such as Maps! because who doesn’t love maps!!

I incorporated the following enhancements into my tutorial:

  • Following the R style guide (e.g., by Hadley Wickham, Google, or the Coding Club style guides).
  • Implementing changes to the style and aesthetics of plots, including axis titles, legends, and color schemes for all plots.
  • Ensuring that the tutorial remains up-to-date with changes in {ggplot2} (current version: 3.4.0).
  • Modifying data import methods to utilize GitHub as a data source.
  • Offering additional tips on various topics such as chart selection, color palettes, title modifications, adding lines, adjusting legends, annotations with labels, arrows and boxes, multi-panel plots, Geospatial Visualizations and interactive visualizations. …

What you’ll discover