【发布时间】:2016-01-29 18:50:41
【问题描述】:
我有三个地块,我想将它们堆叠起来,缩小底部的 2 个,并确保它们垂直对齐。我可以做一个或另一个,但不能两者兼而有之。正如您在图 1 中看到的,这些图是垂直对齐的,但我需要缩小底部的两个;在图 2 中,底部的两个已缩小,但未垂直对齐。
如何缩小底部的两个图并确保所有图都垂直对齐?
这是一个例子:
ggplot:
library(gridExtra)
library(ggplot2)
library(cowplot)
a <- ggplot(data = diamonds, mapping = aes(y = carat, x = price)) + geom_line()
b <- ggplot(data = diamonds, mapping = aes(x = clarity)) + geom_bar()
c <- ggplot(data = diamonds, mapping = aes(x = color)) + geom_bar()
情节 1:
plot_grid(a, b, c, labels=c("", "", ""), ncol = 1, nrow = 3, align = "v")
情节 2:
grid.arrange(a,b,c, ncol = 1, nrow = 3, widths = c(1), heights = c(1,.3,.3))
【问题讨论】:
-
标记为可能的重复。请参阅example #1、example #2 和 example #3。
-
发布问题时请包含所有
library声明。