【发布时间】:2016-12-20 20:54:42
【问题描述】:
我需要将多个图放置在彼此下方,并且我希望边距和图形区域的宽度相同,以便它们整齐地对齐。请注意,我需要两个单独的地块,而不是一个联合地块。我想将每个文件保存在一个单独的 PNG 文件中。我只希望它们的结构(边距、图形区域大小)相同。
library(ggplot2)
d <- data.frame(label=c("some very longe label with lots of text",
"another long label with lots of text",
"short",
"also short",
" short",
" also short"),
x = 1:6)
ggplot(d[1:2, ], aes(label, x)) + geom_bar(stat = "identity") + coord_flip()
ggplot(d[3:4, ], aes(label, x)) + geom_bar(stat = "identity") + coord_flip()
我想要的是情节 2 具有与情节 1 中相同的左边距宽度,或多或少如下所示,当然不添加额外的空白;)
在基本图形中,我将相应地设置par("mar")。
如何在 ggplot 中实现这一点?
【问题讨论】: