How to get dot and error bar plot (ggline without the lines) using ggpubr?

  Kiến thức lập trình

I have gone through a few tutorials on using ggpubr and I seem to be getting the hang of it. Instead of the ggline() plot, however, I want a dot and error bars plot only (i.e., what we get with ggline, but without the line). I usually make this graph using geom_point() + geom_bar() in ggplot but since ggpubr has its own plot functions I’m not sure how to use the stat_compare_means() and stat_pvalue_manual() to add the significance indicators to the type of plot I want.

Below is the code I’m using, but I’d like to make it so that I get a picture similar to the one I’ve uploaded here: desired graph type

# Line plot of mean +/-se
ggline(ToothGrowth, x = "dose", y = "len", add = "mean_se")+
  stat_compare_means() +                                         # Global p-value
  stat_compare_means(ref.group = "0.5", label = "p.signif",
                     label.y = c(22, 29))  

For interested novices like me, here are two good pages on ggpubr:
http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/76-add-p-values-and-significance-levels-to-ggplots/
https://www.datanovia.com/en/blog/how-to-add-p-values-to-ggplot-facets/

I have tried using ggdotplot but that’s more of a scatter plot instead of just giving one point for the mean for each condition.

New contributor

anisac is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT