1

I have the next code to put together around 6 graphs:

# 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)

This is the output, which you will noticed that the sizes from each graph is different. What should I do in order to get all the images the same size?

enter image description here

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
Ale
  • 43
  • 6
  • 1
    I do not have your data to try it out, but how does it react if you add `align="hv"` in `plot_grid()` function? For data, you could also try to post the output of `dput(head(HiBAP1517 , 20))` or sample it `dput(df[sample(1:nrow(df), 20),])` or something in these directions. – Valentin_Ștefan Dec 27 '18 at 20:29
  • Maybe this https://stackoverflow.com/a/53287398/786542? – Tung Dec 28 '18 at 06:20
  • Yes, adding `align="hv"` in `plot_grid()` does work for me. Thanks – Kay0818 Feb 17 '22 at 12:36

0 Answers0