Plot multiple ggplot2 on same page

后端 未结 2 778
故里飘歌
故里飘歌 2021-01-03 09:36

I have a working loop which generates and can save individual plots from each file saved in a directory.

I want to plot all of the returned plots in a single file as

2条回答
  •  独厮守ぢ
    2021-01-03 10:00

    I did recently the same. I used grid.arrange().

    library(ggplot2)
    library(gridExtra)
    library(grid)
    
    p1<-ggplot()+geom_line(aes(x=1:10,y=1:10))
    p2<-ggplot()+geom_line(aes(x=1:10,y=1:10))
    p3<-ggplot()+geom_line(aes(x=1:10,y=1:10)) 
    p4<-ggplot()+geom_line(aes(x=1:10,y=1:10))
    grid.arrange(p1,p2,p3,p4, ncol=1, top=textGrob("Multiple Plots", gp=gpar(fontsize=12, font = 2)))
    

提交回复
热议问题