我正在尝试为grid.arrange图添加脚注。我在这个可重复的例子中提出了我的想法: )
library(ggplot2)
library(gridExtra)
library(grid)
library(gtable)
summary(anscombe)
p1 <- ggplot(anscombe) + geom_point(aes(x1, y1), color = "darkorange", size = 3) + theme_bw()
p2 <- ggplot(anscombe) + geom_point(aes(x2, y2), color = "darkorange", size = 3) + theme_bw()
p3 <- ggplot(anscombe) + geom_point(aes(x3, y3), color = "darkorange", size = 3) + theme_bw()
p4 <- ggplot(anscombe) + geom_point(aes(x4, y4), color = "darkorange", size = 3) + theme_bw()
title <- textGrob("Some title",
gp=gpar(fontsize=20,fontface=2))
source1<- textGrob("Source: https://rpubs.com/neilfws/91339",
hjust=0,x=0,y=1,
gp=gpar(fontsize=10,fontface=3))
grid.arrange(arrangeGrob(p1,p2,p3,p4, ncol=2, sub = source1), top = title)
此代码生成该图片:
图表下面有很大的空间。如何摆脱这种局面?它为什么创建?