Side-by-side plots with ggplot2

后端 未结 13 2481
轮回少年
轮回少年 2020-11-22 02:06

I would like to place two plots side by side using the ggplot2 package, i.e. do the equivalent of par(mfrow=c(1,2)).

For example, I would like to have t

13条回答
  •  后悔当初
    2020-11-22 02:20

    The cowplot package gives you a nice way to do this, in a manner that suits publication.

    x <- rnorm(100)
    eps <- rnorm(100,0,.2)
    A = qplot(x,3*x+eps, geom = c("point", "smooth"))+theme_gray()
    B = qplot(x,2*x+eps, geom = c("point", "smooth"))+theme_gray()
    cowplot::plot_grid(A, B, labels = c("A", "B"), align = "v")
    

提交回复
热议问题