Thanks @jrkrideau
So, I learn more. If I set up as below
dat1 <- data.frame(xx = 1:20, yy = 20:1)
pset1 <- geom_line(colour = "red")
pset2 <- theme_light()
p <- ggplot(dat1, aes(xx, yy))
I can declare pset1, pset2 and more anywhere in the code as long as it is before I attempt to use them.
What cannot be done is to combine them.
# All these are invalid
pset1 <- geom_line(colour = "red") + theme_light()
pset_all = pset1 + pset2
pset_all <- pset1 + pset2
All of these give the error Cannot add ggproto objects together. Did you forget to add this object to a ggplot object?
But this works
p + pset1 + pset2
So, back to my original question. I can create plot settings in advance and apply them when I call a plot. The reason I couldn't get it to work is that I was trying to combine multiple settings.
This achieves what I wanted to do, which is to have a library of plot settings that I can apply to each relevant plot.
The benefits are tidier code and the ability to change multiple plots with a small code change.