这是一个微不足道的问题,但我仍然想解决这个问题。我正在使用 marrangeGrob
和 ggsave
导出一系列图表。我想更改使用 marrangeGrob
生成的页码的默认位置,从页面顶部到右下角。
基于这个问题; Remove page numbers from marrangeGrob (or arrangeList) pdf ,我可以包含参数 top = NULL, Bottom = quote(paste("page", g, "of", pages))
将页码移至每页的底部,但是页码仍然位于中心。
我可以在paste
语句的开头添加很多空间,因此:“page”
但这看起来真的很难看。有更好的方法吗?
示例数据
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")
最佳答案
您可以传递一个 grob 而不是字符串,
bottom = quote(grid::textGrob(paste("page", g, "of", npages), x=1, hjust=1))
关于r - R中使用marrangeGrob和ggsave的页码位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49646768/