Reputation: 2530
This is a trivial question, but one I would still like to solve. I am using marrangeGrob
and ggsave
to export a series of graphs. I would like to change the default position of the page numbers produced with marrangeGrob
, from the top of the page to bottom right.
Based on this question; Remove page numbers from marrangeGrob (or arrangeList) pdf, I can include the arguments top = NULL, bottom = quote(paste("page", g, "of", pages))
to shift the page number to the bottom of each page, but the page number is still in the centre.
I could add a lot of space to the start of the paste
statement, thus: " page"
but that looks really ugly. Is there a better way to do this?
Sample data
library(ggplot2)
library(gridExtra)
# Create some plots
p1 <- qplot(mpg, wt, data = mtcars, colour = cyl)
p2 <- qplot(mpg, data = mtcars) + ggtitle("title")
p3 <- qplot(mpg, data = mtcars, geom = "dotplot")
# Combine into a list, and change where page numbers will appear
Export <- marrangeGrob(list(p1, p2, p3), nrow = 2, ncol = 1, top = NULL,
bottom = quote(paste("page", g, "of", npages)))
# Export to a pdf file
ggsave(filename = "multipage.pdf", Export, width = 7, height = 10, units = "in")
Upvotes: 2
Views: 1121
Reputation: 56
You can pass a grob rather than a string,
bottom = quote(grid::textGrob(paste("page", g, "of", npages), x=1, hjust=1))
Upvotes: 4