grid.layout in ggplot

前端 未结 3 1731
情话喂你
情话喂你 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:37

    If you use markdown, use fig.height in each code chunk for each plot:

    ```{r pw, fig.height = 2.66, echo = F}
    pw
    ```
    ```{r px, fig.height = 2.66, echo = F}
    px
    ```
    ```{r pz, fig.height = 2.66, echo = F}
    pz
    ```
    
    0 讨论(0)
  • 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

    0 讨论(0)
  • 2020-12-13 16:49

    You can also use the multiplot() function, which could be customized to suite your needs: http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/

    0 讨论(0)
提交回复
热议问题