How to add notes to a ggplot

severin picture severin · Jul 16, 2019 · Viewed 8.6k times · Source

I would like to write some notes under my ggplot. I did my data analysis in R and using now the markdown package to write my thesis. This means I can easily include variables in the markdown script. In that script I create some ggplots and was wondering if there is an easy way to write those explanations to the plot. For tables, it is pretty straight forward. %>% footnote(general="") does the trick.

Is there something like that for plots?

Answer

Ankur Sinha picture Ankur Sinha · Jul 16, 2019

Perhaps you are looking for something like this?

p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() + labs(title = "Your title", caption = "Your long reference footnote goes in here")

You need to use the caption parameter from labs() function.

Example:

enter image description here