Why program with {ggplot2}?

To reduce duplicated code, build up repeated components

Can also generalize code to allow for flexibility

Plot components are objects!

One example of a component of a plot is this one below:

bestfit <- geom_smooth(
  method = "lm", 
  se = FALSE, 
  colour = alpha("steelblue", 0.5), 
  linewidth = 2)
class(bestfit)
[1] "LayerInstance" "Layer"         "ggproto"       "gg"