marrangeGrob设置字幕
我有一个函数可以在同一个文档中对多个绘图进行分组,我使用gridExtra::marrangeGrob()函数。我想在页码指示下方加上标题或副标题 我有一种奇怪的行为 在第一个例子中,我得到一个错误,表明它没有找到subtitle变量。 当我在函数声明之外声明subtitle变量时,它会将我放在文档中该值marrangeGrob设置字幕,r,gridextra,R,Gridextra,我有一个函数可以在同一个文档中对多个绘图进行分组,我使用gridExtra::marrangeGrob()函数。我想在页码指示下方加上标题或副标题 我有一种奇怪的行为 在第一个例子中,我得到一个错误,表明它没有找到subtitle变量。 当我在函数声明之外声明subtitle变量时,它会将我放在文档中该值 pl <- lapply(1:20, function(.x) qplot(1:10, rnorm(10),
pl <- lapply(1:20, function(.x) qplot(1:10, rnorm(10),
main=paste("plot", .x))+
labs(x="", y="", title=""))
subtitle <- "b"
wrap_mg(lp = pl, name = "name.pdf", width = 400, height = 350,
subtitle = "a") # if subtitle <- "b" is commented on I get a error:
# Error in is.list(val) : object 'subtitle' not found
# else in my document a get the value "b"
#' @title Merge plot.
#' @description Merge plot from a list.
#' @param lp list - list of plot.
#' @param name character - name file.
#' @param width numeric - Width.
#' @param height numeric - Height.
#' @param subtitle character - subtitle of document.
#' @export
#'
wrap_mg <- function(lp, name, width, height,
subtitle){
lay <- rbind(c(1,2,3),
c(4,5,6),
c(7,8,9))
ml <- gridExtra::marrangeGrob(lp, nrow=3, ncol=3,
layout_matrix=lay,
left="left",
bottom="bot",
top = quote(paste("page", g, "of",
npages, "\n", "\n",
subtitle))
)
ggsave(plot = ml, filename = name, dpi = 400, device = "pdf",
width = width, height = height,
units = c("mm"),limitsize = FALSE)
}
pl如何使用bquote
例如top=bquote(粘贴(“page”,g,“of”,npages,”\n“,(副标题))
如何使用bquote
例如top=bquote(粘贴(“page”,g,“of”,npages,”\n“,(副标题))