How to add standard error bars to a box and whisker plot using ggplot2?

后端 未结 1 1508
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-10 01:24

I\'m trying to add standard error bars to my data similar to the ones seen on the box plots near the end of the answer on this question: https://stats.stackexchange.com/question

1条回答
  •  你的背包
    2021-02-10 02:13

    There is a mean_se function in ggplot2 which does exactly what you want.

    library(ggplot2)
    ggplot(PlantGrowth, aes(group, weight))+
      stat_boxplot( aes(group, weight), 
        geom='errorbar', linetype=1, width=0.5)+  #whiskers
      geom_boxplot( aes(group, weight),outlier.shape=1) +    
      stat_summary(fun.y=mean, geom="point", size=2) + 
      stat_summary(fun.data = mean_se, geom = "errorbar")
    

    0 讨论(0)
提交回复
热议问题