That should be covered in the original A layered grammar of graphics paper: https://vita.had.co.nz/papers/layered-grammar.html
And then there is an entire ggplot2 book (there are many, but this one was written by Hadley): https://ggplot2-book.org/
And then there is an entire ggplot2 book (there are many, but this one was written by Hadley): https://ggplot2-book.org/