library(tidyverse)
<- read_csv("data/surveys.csv") surveys
6 Plotting data
Learning objectives
6.1 Context
We now have a good grasp of how data is commonly structured, with variables in columns and observations in rows. This is the perfect format for visualising data.
6.2 Introducing plotting
To create a plot we’ll need three things:
- data
- mapping aesthetics
- specify the type of plot
6.2.1 Start plotting
- LO: plotting with ggplot2
6.2.2 Building up plots
- LO: layering plots
ggplot(data = surveys,
mapping = aes(x = weight, y = hindfoot_length)) +
geom_point()
6.2.3 Changing plots
- LO: changing aesthetics (colour, fill, transparency, size)
6.3 Summary
Key points