How can I align multiple plots by their titles instead of plot area?

后端 未结 2 940
北恋
北恋 2021-01-14 04:09

I\'m using egg to align multiple plots on a page. I\'m wondering if it\'s possible to align two columns by the titles a) and c) instead of plot are

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-14 05:04

    I found another way by using cowplot package

    left_col <- cowplot::plot_grid(p1 + ggtitle(""), p2 + ggtitle(""), 
                                   labels = c('a)', 'b)'), label_size = 14,
                                   ncol = 1, align = 'v', axis = 'lr') 
    cowplot::plot_grid(left_col, p3 + ggtitle(""), 
                       labels = c('', 'c)'), label_size = 14,
                       align = 'h', axis = 'b')
    

    See also here

    Edit:

    A recently developed package patchwork for ggplot2 can also get the job done

    library(patchwork)
    
    {
      p1 + {p2} + patchwork::plot_layout(ncol = 1)
    } / p3 + patchwork::plot_layout(ncol = 2)
    

提交回复
热议问题