我已使用以下代码创建了地块列表:
plots <- list()
for(i in 1:(k*k)){
plots[[i]] <- ggplot(subset(mean_conf, Names == Names[i]), aes(x=nob)) +
geom_line (aes(y = Mean), color = "black") +
geom_line (aes(y = Left_Interval), color="black", linetype="twodash") +
geom_line (aes(y = Right_Interval), color="black", linetype="twodash") +
theme(axis.title.x=element_blank(),axis.title.y=element_blank()) + expand_limits(y = 0)
}
使用grid.arrange函数(do.call(grid.arrange,plots)
)带来下图
我检查了不同的功能,但是找不到解决我问题的方法。我将不胜感激任何意见,建议和帮助。
gridExtra和grid可能是您所追求的布局的朋友。
这里是10的首发菜。
library(ggplot2)
library(gridExtra)
library(grid)
p <- ggplot(mtcars, aes(disp, wt)) + geom_line()
ver <- textGrob("Plots verion 1", gp = gpar(fontsize = 15))
A_top <- textGrob("A", gp = gpar(fontsize = 15))
A_left <- textGrob("A", gp = gpar(fontsize = 15), x = unit(45, "mm"), y = unit(15, "mm") )
B_top <- textGrob("B", gp = gpar(fontsize = 15))
B_left <- textGrob("B", gp = gpar(fontsize = 15), x = unit(45, "mm"), y = unit(15, "mm"))
grid.arrange(ver, A_top, B_top, A_left, p, p, B_left, p, p,
top = textGrob("Title", gp=gpar(fontsize = 20), x = unit(125, "mm")),
bottom = textGrob("Subtitle", gp=gpar(fontsize = 10), x = unit(65, "mm")),
ncol = 3,
widths = unit(c(50, 75, 75), "mm"),
heights = unit(c(10, 75, 75), "mm"))
这给您:
可以浏览以下链接来优化布局
https://cran.r-project.org/web/packages/gridExtra/vignettes/arrangeGrob.html#title-andor-annotations