【问题标题】:Shrink and Align plots with grid.arrange使用 grid.arrange 缩小和对齐图
【发布时间】: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))

【问题讨论】:

标签: r ggplot2


【解决方案1】:

试试rel_heights 参数:

plot_grid(a, b, c, ncol = 1, align = "v", rel_heights = c(3, 1, 1))

【讨论】:

  • 这就是我要找的论据。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-06-26
  • 1970-01-01
  • 2011-05-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多