I'm making some pdf files with multiple graphs on each page, and, when I use marrangeGrob from the gridextra package to make those graphs, the first page is always blank. How can I make the plots start on the first page? Here's some example code:
library(gridextra)
library(ggplot2)
data(iris)
Plotlist <- list()
Plotlist[[1]] <- ggplot(data = subset(iris, Species == "setosa"),
aes(x = Sepal.Width, y = Sepal.Length)) +
geom_point()
Plotlist[[2]] <- ggplot(data = subset(iris, Species == "versicolor"),
aes(x = Sepal.Width, y = Sepal.Length)) +
geom_point()
Plotlist[[3]] <- ggplot(data = subset(iris, Species == "virginica"),
aes(x = Sepal.Width, y = Sepal.Length)) +
geom_point()
pdf("iris.pdf", width = 8.5, height = 11)
marrangeGrob(Plotlist, nrow = 2, ncol = 1)
dev.off()
The 2nd page of the pdf even says at the top, "Page 1 of 2", so there's some disconnect somewhere.
Plotlist <- lapply(split(iris, iris$Species), function(S){ ggplot(S, aes(x = Sepal.Width, y = Sepal.Length)) + geom_point() })
– Writing