我真的很喜欢 patchwork 包,多个地块的对齐通常比其他包(cowplot/gridextra)更好也更容易实现。
但是,我无法解决的一件事:是否可以在拼凑中忽略 x 轴对齐,而只对齐所有其他元素?或者手动调整拼凑中的这个x轴对齐后缀?见附图:如果可能,我希望补丁 B 和 C (Petal.Length) 中的 x 轴标题更靠近 x 轴。
生成图像的代码:
library(ggplot2)
library(patchwork)
plot.1 <- ggplot(iris, aes(x = Species, y = Petal.Width)) +
geom_boxplot() +
scale_x_discrete(labels = c("A very\nvery\nlong\nlabel", "","")) +
labs(x = element_blank())
plot.2 <- ggplot(iris, aes(x = Petal.Length, y = Petal.Width)) +
geom_point()
(plot.1 |plot.2)/(plot.2|plot.1) +
plot_annotation(tag_levels = "A")