【发布时间】:2011-07-10 18:05:24
【问题描述】:
我正在尝试根据此表将两个 ggplot2 图合并为一个:
Type RatingA RatingB
1 One 3 36
2 Two 5 53
3 One 5 57
4 One 7 74
5 Three 4 38
6 Three 8 83
我想制作两个散点图,y 轴为评分的平均值,x 轴为输入。
这是我创建每个图表的方式:
p1 <- ggplot(test, aes(x=reorder(Type, RatingA, mean), y=RatingA)) +
stat_summary(fun.y="mean", geom="point")
p2 <- ggplot(test, aes(x=reorder(Type, RatingB, mean), y=RatingB)) +
stat_summary(fun.y="mean", geom="point")
由于 p1 和 p2 具有相同的 x 轴,我希望它们垂直排列。我查看了 facet_align,但找不到可以完成这项工作的东西。
【问题讨论】:
-
另请参阅this,了解多种方法(2018 年 9 月)