如何使用 ggpubr 中的 ggbarplot 使用处理后的数据绘制误差线?

How to plot error bar using processed data by ggbarplot in ggpubr?

原始数据应该在ggpubr的ggbarplot中提供,通过add = 'mean_sd'绘制误差条,是否可以使用处理数据绘制,如

library(ggpubr)
 df <- data.frame(dose=c("D0.5", "D1", "D2"),
         len=c(4.2, 10, 29.5), sd = c(0.1, 0.2, 0.5)) 
ggbarplot(df, x= 'dose', y = 'len', add = 'mean_sd', error.plot = 'upper_errorbar') # can not be run

谢谢

我认为您需要添加对 geom_errorbar 的单独调用:

ggbarplot(df, x= 'dose', y = 'len') +
+ geom_errorbar(aes(ymin = len - 1.96*sd, ymax = len + 1.96*sd), width=.2)