Overview

ggplot2 is a grammar of graphics, a coherent system for describing and building graphs.

Tips

Lesson

  1. Data visulization with ggplot2
  2. ggfortify - plot some popular R packages with ggplot2
  3. geom_map
  4. geom_sf - ggplot2 working with simple feature and the simple feature package for geo-spatial analysis
  5. ggmap - raster map tiles from popular online mapping services
  6. interactive maps and charts with R

Exercise

  1. Plot the daily bike counts with ggplot2; Experiement with different options (bar, line, etc) and select the one works best for you;
  2. Plot weekly, monthly, and annual bike counts for the three bridges;
  3. Now think about and try out different ways to plot weather information along with your daily bike counts (separately or together);
  4. You can combine time series stats and ggplot2/ggfortify to plot seasonal variation, trend and noise separately. See here for an example of how to do this.

Sample code

Resources:

  1. ggplot2 tutorial by Dr. Jenny Bryan
  2. R4DS Graphics for communication
  3. The ggplot2 Cheat Sheet - RStudio
  4. R Graphics Cookbook