Specify widths and heights of plots with grid.arrange

前端 未结 2 663
小鲜肉
小鲜肉 2020-12-02 10:55

I have three plots and I try to combine them with grid.arrange. The last plot should have a smaller height than the first two plots and all the plots should have the same wi

2条回答
  •  天涯浪人
    2020-12-02 11:51

    Try plot_grid from the cowplot package:

    library(ggplot2)
    library(gridExtra)
    library(cowplot)
    p1 <- qplot(mpg, wt, data=mtcars)
    p2 <- p1
    p3 <- p1 + theme(axis.text.y=element_blank(), axis.title.y=element_blank())
    plot_grid(p1, p2, p3, align = "v", nrow = 3, rel_heights = c(1/4, 1/4, 1/2))
    

提交回复
热议问题