举例:将做的均值线叠加在散点图之上
使用geom_line
ggplot(aes(x=age,y=friend_count),data = pf)+geom_point(alpha = 1/10,position = position_jitter(h=0),color="pink")+coord_cartesian(xlim=c(13,90))+coord_trans(y="sqrt")+geom_line(stat = "summary",fun.y=mean)+geom_line(stat = "summary",fun.y=quantile,fun.args=list(probs =0.1),linetype =2 ,color="blue")+geom_line(stat = "summary",fun.y=quantile,fun.args=list(probs =0.9),linetype = 2,color = "blue")+geom_line(stat = "summary",fun.y=quantile,fun.args=list(probs =0.5),linetype=2,color="blue")
示例如图