I'm using the following code:
我使用以下代码:
library (ggplot2)
df=data.frame(score=c(1,3,5,9,7,8,4,1,2,6,1,6,2,1,3,1,3,5,8,4),
age=c(2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3))
ggplot(data=df,aes(x=age,y=score))+
geom_point(position=position_jitter(width=.1),aes(color=age))+
geom_line(stat = "hline", yintercept = "mean",aes(group=age))+
stat_summary(geom = "line", fun.y="mean",aes(yend=..y..),width=.5)+
stat_summary(fun.data="mean_cl_boot",geom="errorbar",width=.5)+
theme_classic()
libr