如何在R中为使用grid.arrange()创建的每个列指定标题?

lhcgjxsq  于 2023-06-19  发布在  其他
关注(0)|答案(1)|浏览(135)

有人知道是否可以在用grid. arrangement()创建的图表的每一列中给予一个标题?我知道这是可能的,给予一个整体的标题和标题,每个图表,但我只需要一个列标题。非常感谢!

grid.arrange(c1b, c2a, c3d, c2b, c3a, c2d, c3b, c1a, c1d, ncol=3, nrow=3)
wtzytmuj

wtzytmuj1#

user20650

library(tidyverse)
library(gridExtra)

#create a bunch of line graphs with the mtcars dataset
graph1 <- ggplot(mtcars, aes(x = mpg, y = disp)) + geom_line()
graph2 <- ggplot(mtcars, aes(x = mpg, y = hp)) + geom_line()
graph3 <- ggplot(mtcars, aes(x = mpg, y = drat)) + geom_line()
graph4 <- ggplot(mtcars, aes(x = mpg, y = wt)) + geom_line()

grid.arrange(arrangeGrob(graph1, graph2, top = "Column A"),
             arrangeGrob(graph3, graph4, top = "Column B"), ncol = 2)

相关问题