此代码无法按预期工作ggplot2 0.9.3
(适用于早期版本的 ggplot2,请参见此处)。这个问题有解决方法吗?
library(ggplot2)
p <- qplot(as.factor(dose), len, data=ToothGrowth, geom = "boxplot", color = supp) + theme_bw()
p <- p + labs(x="Dose", y="Response")
p <- p + stat_summary(fun.y = mean, geom = "point", color = "blue", aes(group=supp))
p <- p + stat_summary(fun.y = mean, geom = "line", aes(group = supp))
p <- p + theme(axis.title.x = element_text(size = 12, hjust = 0.54, vjust = 0))
p <- p + theme(axis.title.y = element_text(size = 12, angle = 90, vjust = 0.25))
print(p)
编辑
这条线
p <- p + stat_summary(fun.y = mean, geom = "line", aes(group = supp))
产生以下警告
geom_path:每个组仅包含一个观察值。需要调整群体审美吗?