Introduction to ggplot2

Nathalie Vialaneix and Sébastien Déjean
12 octobre 2018

ggplot2

Basic concepts about pictures to understand ```ggplot2```

iris

A picture is worth a thousand words

challenger Edward Tufte about 1986 Challenger space shuttle disaster

notes challenger figure challenger

Ref: Visual explanations: image and quantities, evidence and narrative. Chap. 5 deals with the Challenger disaster.

Base graphics vs ggplot2

Base graphics

  • directly available from R
  • easy to use for beginners
  • is less verbose for simple / canned graphics
  • has methods (plot works for many different ojects)

ggplot2

  • R graphing package by Hadley Wickham based on the Grammar of Graphics (Wilkinson, 2005)
  • is less verbose for complex / custom graphics: plots can be iteratively built up and edited later
  • carefully chosen defaults = publication-quality graphics in seconds
  • ggplot2 is a part of tidyverse (www.tidyverse.org) a collection or R packages designed for data science
  • data should always be tidy data in a data.frame

tidy data

ggplot2 extensions: ggbio

ggplot2 resources online

Credits

Slides built with material coming from:

Credit for figures