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

Time:02-17

The original data should be provided in ggbarplot of ggpubr to plot error bar by the add = 'mean_sd', is it possible to plot using the processing data, like

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

Thanks

CodePudding user response:

I think you need to add a separate call to geom_errorbar:

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

enter image description here

  • Related