Если кто-то ищет решение ggplot2
, вы можете использовать cowplot
или patchwork
пакетов
library(ggplot2)
### examples from cowplot vignettes
plot.mpg <- ggplot(mpg, aes(x = cty, y = hwy, colour = factor(cyl))) +
geom_point(size = 2.5)
plot.diamonds <- ggplot(diamonds, aes(clarity, fill = cut)) +
geom_bar() +
theme(axis.text.x = element_text(angle = 0, vjust = 0.5))
library(cowplot)
### use NULL
plot_grid(plot.mpg, NULL, NULL, plot.diamonds,
labels = c("A", "B", "C", "D"),
ncol = 2
)
# Note: if you want to initialize an empty drawing canvas, use ggdraw()
library(patchwork)
### use plot_spacer()
plot.mpg + plot_spacer() + plot_spacer() + plot.diamonds +
plot_layout(ncol = 2) +
plot_annotation(
title = "Plot title",
subtitle = "Plot subtitle",
tag_levels = "A",
tag_suffix = ")"
)
Создано в 2019-03-17 по представителю пакета (v0.2.1.9000)