Image credit: Charles Joseph Minard


In the first half part of this module you’ll watch a video that walks through the basics of using ggplot2, a system for declaratively creating graphics, based on The Grammar of Graphics. Then, you’ll complete two active coding lesson in Datacamp.

Learning objectives

  • Understand the advantages of a layered grammar of graphics
  • Understand and be able to modfiy the basic code for producing plots with ggplot2
  • Understand themes for ggplot2
  • Know how to find and use colors in creating graphics in R

Files you’ll need

Download the files below and place them on your desktop. If any of these files do not download when you click on them, simply right-click and choose ‘copy link address’, then open a new browser tab, paste the path into your web-browser URL bar, and hit enter.

R script - I’ll use this script to demonstrate basic aspects of using ggplot2.

Data for reproducing ‘Napoleon’s March’




Data for reproducing ‘Climate Spiral’


Lecture video

Lecture slides on iCloud

Active coding exercise in Datacamp

Introduction to data visualization with ggplot2

Reading (optional)

The Grammar of Graphics, Second Edition - This 2005 book makes the philosophy and application of a grammar for graphics. A critical book in dataviz.

A Layered Grammar of graphics - Seminal 2010 paper by Hadley Wickham that builds on Wilkinson’s work above and introduces ggplot2 and the concept of a layered grammar for graphics in R.

ggplot2 cheatsheet – a very helpful guide as we continue to use ggplot2 for all of our plotting needs.

Gallery of ggplot2 graphics - Take a look at some of the various ways to graph your data and the underlying R code.

R Graphics Cookbook - If you end up using R to make a lot of graphs, you will find this book to be an important reference. It’s free too!