ggplot2 绘图 调整画布的大小

 

001、

library(cowplot)

library(ggplot2)
a <- ggplot(mtcars, aes(x = mpg)) + geom_histogram(binwidth = 4) + 
  theme(plot.margin=unit(c(1, 1, 1, 1),'cm'))

b <- ggplot(mtcars, aes(x = mpg)) + geom_histogram(binwidth = 4) + 
  theme(plot.margin=unit(c(2, 2, 2, 2),'cm'))

c <- ggplot(mtcars, aes(x = mpg)) + geom_histogram(binwidth = 4) + 
  theme(plot.margin=unit(c(3, 3, 3, 3),'cm'))

d <- ggplot(mtcars, aes(x = mpg)) + geom_histogram(binwidth = 4) + 
  theme(plot.margin=unit(c(4, 4, 4, 4),'cm'))

plot_grid(a, b, c, d, nrow=2,labels = c('aaa', 'bbb', 'ccc', 'ddd'))

 

 

 

posted @ 2022-08-02 00:12  小鲨鱼2018  阅读(4286)  评论(0编辑  收藏  举报