As just discussed in the previous section, we saw how important the concept of layers was when creating a plot with
ggplot2. These layers are then combined with a coordinate system and other transformations which then generate the final plot. But what exactly are the layers? In the grammar of graphics as implemented in
ggplot2, the layers are responsible for the objects that we see in the graph. Each layer can come from a different dataset, have different geometry, and have a different aesthetic mapping. As you can see in Figure 3.1, the layers are composed of several components—the
position adjustment. Not all these components are needed in order to create a layer, but a minimal layer can be ...