Slide 1

Slide 1 text

Plotting in Open Source Statistical Programming map courtesy of James Cheshire (spatialanalysis.co.uk/2012/02/great-maps-ggplot2/)

Slide 2

Slide 2 text

Tables Data Graphs Statistics Understanding Sigmaplot Excel SAS Why do your plotting in R? Simpler workflow:

Slide 3

Slide 3 text

Tables Data Statistics Understanding Graphs Why do your plotting in R? Simpler workflow:

Slide 4

Slide 4 text

Why do your plotting in R? Flexible and beautiful graphics:

Slide 5

Slide 5 text

Why do your plotting in R? Flexible and beautiful graphics:

Slide 6

Slide 6 text

Why do your plotting in R? Flexible and beautiful graphics:

Slide 7

Slide 7 text

Enough slides! Now for a live demo

Slide 8

Slide 8 text

* Challenge 1: Building a plot layer by layer 1. Use the 'iris' dataset to build the following three plots: a. A plot of Sepal.Length vs. Sepal.Width b. The same plot, but coloured by 'Species' c. A plot of Petal.Length vs. Species

Slide 9

Slide 9 text

* Challenge 2: Playing with aesthetics and geoms 1. Use the qplot function and the 'iris' dataset to re- build the following three plots: a. A plot of Sepal.Length vs. Sepal.Width b. The same plot, but coloured by 'Species' c. A plot of Petal.Length vs. Species 2. For the plot in part 'c', try changing the geom argument to "boxplot". Try building a graph with both points and boxplot on them

Slide 10

Slide 10 text

* Challenge 3: Faceting and scaling 1. Try to build the following plots using the iris data: a. Petal.Width vs. Petal.Height, faceted in a row by Species; and the same plot by column b. Sepal.Width vs. Sepal.Height, with the x-axis log-transformed, the y-axis log-transformed, and both axes log-transformed

Slide 11

Slide 11 text

ggplot2: using the Grammar of Graphics ggplot2: a different way of plotting: building plots by describing what you want, and let it figure out how to plot it.

Slide 12

Slide 12 text

ggplot2: using the Grammar of Graphics ggplot2: Builds plots out of simpler components: ● data ● aesthetics: e.g. coordinates, colour, size of points ● geoms: the type of plot layer: line, point, etc. ● facets: organizing graphs into subplots ● transforms: logs, square roots, continuous to discrete etc. ● stats: functions of the raw data ● coordinates: e.g. Euclidean, map coords, polar ● themes: font size, grids, etc.

Slide 13

Slide 13 text

Further reading Plotting in general: R Graphics The R Book ggplot2 references: The creator, Hadley Wickham's website The in-depth documentation website The book: ggplot2: Elegant Graphics for Data Analysis