Adding x and y laxis label to ggplot-grid build with cowplot

后端 未结 2 627
情书的邮戳
情书的邮戳 2021-01-16 10:33

I produced a grid with cowplot:

library(ggplot2)
library(cowplot)

ggg1 <- ggplot(mtcars, aes(mpg,vs)) + geom_point() +
  theme(axis.title.x=element_blank         


        
相关标签:
2条回答
  • 2021-01-16 11:30

    This seems to work...

    plot_grid(plot_grid(ggg1, ggg2, labels=c("", ""), ncol = 1), 
              ggg3, 
              labels=c("", ""), 
              ncol =2,  
              scale=0.9) + #perhaps reduce this for a bit more space
    draw_label("xlab", x=0.5, y=  0, vjust=-0.5, angle= 0) +
    draw_label("ylab", x=  0, y=0.5, vjust= 1.5, angle=90)
    

    0 讨论(0)
  • 2021-01-16 11:36

    Here's an alternative strategy

    library(grid)
    library(gridExtra)
    library(egg)
    grid.arrange(gtable_cbind(gtable_frame(ggarrange(ggg1, ggg2, draw=F)), 
                              gtable_frame(ggplotGrob(ggg3))),
                 left = textGrob("Left",rot=90), 
                 bottom = textGrob("Bottom"))
    

    enter image description here

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