Add a footnote citation outside of plot area in R?

后端 未结 3 1896
终归单人心
终归单人心 2021-01-30 17:10

I\'d like to add a footnote citation to my 3-panel facet grid plot produced in R. It\'s a footnote to credit the data source. I\'d ideally like to have it below and external t

3条回答
  •  天涯浪人
    2021-01-30 17:58

    library(gridExtra)
    library(grid)
    library(ggplot2)
    
    g <- grid.arrange(qplot(1:10, 1:10, colour=1:10) + labs(caption="ggplot2 caption"), 
                  bottom = textGrob("grid caption", x = 1, 
                                    hjust = 1, gp = gpar(fontface = 3L, fontsize = 9)))
    ggsave("plot.pdf", g)
    

    Edit: note that this solution is somewhat complementary to the recent caption argument added to ggplot2, since the textGrob can here be aligned with respect to the whole figure, not just the plot panel.

提交回复
热议问题