September 2018
Beginner
206 pages
4h 27m
English
While we have created some basic ggplots, we haven't really dug much into the aesthetics of plots. There are definitely both some global and plot-specific aesthetics that are very important to know when you're building plots.
One key distinction to master is that when you call something inside of aes(), the aesthetic is mapped to the value of the variable in the data. Outside of an aes() call, the aesthetic is set to a specific value. This is perhaps best understood with an example.
The following code is a bar chart of how many cars have each number of cylinders, where fill is the number of gears the car has, all from mtcars:
ggplot(mtcars, aes(cyl, fill = as.factor(gear))) + geom_bar()
A legend appears to let us know which ...
Read now
Unlock full access