r - 如何更改“grid_arrange_shared_legend”中常见图例的标题?
问题描述
我正在使用“grid_arrange_shared_legend”函数来绘制多个图。生成的图例有一个标题,它是数据框中列的命名方式。但是,我需要将其修改为其他内容。
grid_arrange_shared_legend <- function(plots) {
g <- ggplotGrob(plots[[1]] + theme(legend.position="bottom"))$grobs
legend <- g[[which(sapply(g, function(x) x$name) == "guide-box")]]
lheight <- sum(legend$height)
grid.arrange(
do.call(arrangeGrob, lapply(plots, function(x)
x + theme(legend.position="none"))),
legend,
ncol = 1,
heights = unit.c(unit(1, "npc") - lheight, lheight))
}
解决方案
推荐阅读
- c++ - 当我尝试运行复制构造函数时,为什么会出现“分段错误”?
- c - 使用 `iwlib` 以外的库访问 Wifi 信号的质量
- python - Precurse with open() or .write()?
- javascript - Can a button handle multiple actions?
- python - Error when transforming my Python code to .EXE using Auto Py to Exe
- javascript - Tooltip moves further from mouseover location as I scroll HTML page
- r - R: Concatenating a string to every column in a row (excluding col 1, variable col length, the string is held in col 1 of each row)
- react-native - 使用@terrylinla/react-native-sketch-canvas 发送画布图像
- reactjs - 尝试添加 & { session: Express.Session } 以在遵循 React、Express 和 Typescript 教程时键入 MyContext 时出现“没有导出成员”错误
- java - Spring Boot 应用程序 DispatcherServlet 的入口点没有响应