-1

I have used ggpaired() from ggpubr to plot my scattered data with a connecting line in my groups.

I would like to know what are the boxplots plotting? i.e mean, median, ci, sd, se...?

I have used:

myplt<- ggpaired(data.plt, x = "run", y = "meangamma", color='run',
    line.color = "gray", line.size = 0.4)+
  facet_grid(~ROI, scales='free_x',labeller = labeller(ROI=as_labeller(areas.labs)))+
  guides(col=FALSE)+
  scale_color_manual(values=c('#FDAE61','#ABD9E9'))+ 
  scale_fill_manual(values=c('#FDAE61','#ABD9E9'), guide='none')+
 theme_classic()+
 theme(strip.background = element_blank())+
 theme(aspect.ratio = 2)

However, I would like my boxplots to show mean +- confidence intervals connecting two scatter plots.

This is my plt

aperis
  • 79
  • 1
  • 4
  • 3
    Welcome to SO! It would be easier to help you if you provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including the code your tried, the packages you used and a snippet of your data or some fake data. – stefan Mar 26 '22 at 19:34
  • ... this said: In general a boxplot plots the median, the 25% and 75% percentiles, ... See e.g. `?geom_boxplot` for detailed information on the summary statistics. – stefan Mar 26 '22 at 19:38
  • Hi Stefan, thank you very much. I have now uploaded the code I used together with the output plot. I would like to plot something just like it but with mean +- confidence intervals instead. Thank you very much! – aperis Mar 27 '22 at 11:55
  • I just fixed my plots following https://stackoverflow.com/questions/57763876/how-to-combine-geom-bar-geom-point-and-geom-line-into-one-figure and https://stackoverflow.com/questions/21192002/how-to-combine-2-plots-ggplot-into-one-plot . If needed I'd be happy to share my final code. – aperis Mar 27 '22 at 12:46

1 Answers1

0

I solved my issue by plotting 2 separate plots and overlaying them on to eachother. See code and final plot here.

myplt<-
      ggplot()+
      geom_bar(data=data.plt.summary,aes(x=run, y=mean, fill=run), position='dodge',stat='identity', alpha=0.3, show.legend = FALSE)+
      geom_errorbar(data=data.plt.summary,aes(x=run, ymin=mean-ci, ymax=mean+ci), width=0.4, color='#4575B4', size=0.5,  position=position_dodge(0.9), stat='identity', alpha=0.5)+
        geom_point(data=data.plt, aes(x=run, y=meangamma,color=run)) +
      geom_line(data=data.plt,aes(x=run, y=meangamma,color=run, group=subject))+
      facet_grid(~ROI, scales='free_x',labeller = labeller(ROI=as_labeller(areas.labs)))+
      guides(col=FALSE)+
      scale_color_manual(values=c('#FDAE61','#ABD9E9'))+
      scale_fill_manual(values=c('#FDAE61','#ABD9E9'), guide='none')+
     theme_classic()+
     theme(strip.background = element_blank())+
     theme(aspect.ratio = 2)
aperis
  • 79
  • 1
  • 4