首页 文章

R ggplot stat_summary不一致的结果

提问于
浏览
0

我使用ggplot绘制mtcar数据框中的平均mpg . 我得到每个柱面类的几个点,表示平均值,按vs变量分类 .

library(ggplot2)
ggplot(mtcars, aes(cyl, mpg)) + geom_point(aes(color = factor(vs)), stat = "summary", fun.y = "mean")

如果我通过添加 + geom_point (下面)将这些平均值叠加在原始数据之上,则平均值与上面的平均值不同 . 我究竟做错了什么?为什么手段不一致?

ggplot(mtcars, aes(cyl, mpg)) + geom_point() + geom_point(aes(color = factor(vs)), stat = "summary", fun.y = "mean")

1 回答

  • 0

    多么尴尬 . 我甚至没看过Y轴的刻度 . 谢谢aosmith . stat_summary中没有不一致 .

相关问题