假设我想将以下六个图合并为一个图。
library(ggplot2)
p1 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
p2 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
p3 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
p4 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
p4 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
p5 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
p6 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
Run Code Online (Sandbox Code Playgroud)
为此,我使用 Pachwork 包:
library(patchwork)
(p1 | p2 | p2 ) / (p4 | p5 | p6 ) +
plot_annotation(title = "Perceptual Domain", tag_levels = 'A') &
theme(plot.title = element_text(hjust = 0.5), plot.tag = element_text(size = 15, …Run Code Online (Sandbox Code Playgroud)