我在 facet_wrap
documentation 中有看起来像这个例子的数据:
(来源:ggplot2.org)
我想用整体 View 填充最后一个方面,使用所有数据。
是否有一种简单的方法可以使用 facet_wrap
添加“总”方面? ?为 facet_grid
添加边距很容易,但该选项在 facet_wrap
中不存在.
注意:使用 facet_grid
如果您想要上图中的象限,则不是一个选项,这需要 ncol
或 nrow
来自 facet_wrap
的参数.
最佳答案
library(ggplot2)
p <- qplot(displ, hwy, data = transform(mpg, cyl = as.character(cyl)))
cyl6 <- subset(mpg, cyl == 6)
p + geom_point(data = transform(cyl6, cyl = "7"), colour = "red") +
geom_point(data = transform(mpg, cyl = "all"), colour = "blue") +
facet_wrap(~ cyl)
关于r - 在ggplot2中轻松地将 '(all)' facet添加到facet_wrap?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18933575/