Ggplot2 footnote

What is the best way to add a footnote to the end of a graph created with ggplot2? I tried using a combination of the logic noted here , as well as the annotate ggplot2 function.

 p + annotate("text",label="Footnote", x=unit(1,"npc") - unit(2, "mm"),y=unit(2, "mm"), just=c("right", "bottom"),gp=gpar(cex= 0.7, col=grey(.5))) 

but i get an error

Error in as.data.frame.default (x [[i]], optional = TRUE, stringsAsFactors = stringsAsFactors): cannot convert class c ("unit.arithmetic", "unit") to data.frame

+11
r pdf ggplot2
Jun 14 '10 at 17:33
source share
2 answers

I would use something like this:

 pdf("filename.pdf", width=10, height=6) # open an appropriate graphics device print(p) makeFootnote() # from webpage above (uses grid.text; ggplot2 is based on grid) dev.off() 
+12
Jun 14 '10 at 18:40
source share

labs(caption = "my caption") adds a footnote:

 ggplot(mtcars, aes(mpg, wt, colour = cyl)) + geom_point() + labs(caption = "(Pauloo, et al. 2017)") 

enter image description here

+6
Jul 31 '17 at 7:01
source share



All Articles