如何在多个图的网格中将图调整为相同大小

时间:2018-12-27 18:48:37

标签: r ggplot2 cowplot

我有下一个代码可以将6个图形放在一起:

# Set up the work directory in which all data is gonna be extracted
HiBAP1517 = read.csv("HiBAPPaperv2.csv") #Change name of the file
# Load the ggplot2 package
library(ggplot2) #Run to create plots
library(grid)
library(cowplot)
library(gridExtra)

p1 <- ggplot(HiBAP1517, aes(BPM,Yld)) +
  geom_point(shape=16) + 
  geom_smooth(method=lm, se = F) + 
  theme(axis.title.x = element_text(color="black", size=14, face="bold"),
        axis.title.y = element_text(color="black", size=14, face="bold")) + 
  coord_fixed()

pfinal <- p1 + labs(x = expression("AGDM"[PM]~{}* (gm^{-2})),
                    y = expression("GY "*(gm^{-2}))) + theme(aspect.ratio=1)

plot_grid(pfinal, pfinal2, pfinal3, pfinal4, pfinal5, pfinal6, 
          labels = c("a", "b", "c", "d", "e", "f"), ncol = 3)

这是输出,您会注意到每个图的大小都不同。我应该怎么做才能使所有图像都具有相同的大小?

enter image description here

0 个答案:

没有答案