Say I have three SQUARE plots p1 p2 p3 made from the ggplot2
package. I applied ggarrange
command under ggpubr
package to make a 1*3 plot after that. Here are the commands:
library(ggplot2)
library(ggpubr)
library(gridExtra)
data <- data.frame(matrix(seq(1, 30, 1), 2))
for(i in 1:5){
plot1 <- ggplot(data = data, aes(y = data[, (i*3-2)])) +
theme(aspect.ratio = 1)
plot2 <- ggplot(data = data, aes(y = data[, (i*3-1)])) +
theme(aspect.ratio = 1)
plot3 <- ggplot(data = data, aes(y = data[, (i*3)])) +
theme(aspect.ratio = 1)
p <- ggarrange(plot1, plot2, plot3,
ncol = 3, common.legend = TRUE, legend = "bottom")
grid.arrange(p, top = paste(colnames(data)[i]), heights = c(1, 1))
}
The rmarkdown output (below) shows a large white space below the arranged plots:
Is there any way to remove it? What I thought is to change the default size of canvas..