grid.layout in ggplot

前端 未结 3 1741
情话喂你
情话喂你 2020-12-13 16:04

I\'m using the following code to create three sets of plots in the amazing package ggplot2:

w<-rnorm(100)
x<-rnorm(100)
y<-rnorm(100)
z<-rnorm(10         


        
3条回答
  •  别那么骄傲
    2020-12-13 16:47

    You'll probably have a better time using grid.arrange(), from the gridExtra package:

    p1 <- pw + geom_point() + facet_grid(.~g, scales='fixed') + coord_equal() +   
          stat_smooth(method='lm')
    p2 <- px + geom_point() + facet_grid(.~g, scales='fixed') + coord_equal() + 
          stat_smooth(method='lm')
    p3 <- pz + geom_point() + facet_grid(.~g, scales='fixed') + coord_equal() +   
          stat_smooth(method='lm')
    
    grid.arrange(p1, p2, p3, ncol=1)
    

    enter image description here

提交回复
热议问题