0

I'm trying to plot and add error bars, and somehow today it decided to plot like this. I'm clearly missing something, what is wrong with these error bars?!

hits <- ggplot(coverage_data, aes(Phenotype, Hits, fill=Phenotype)) +
  geom_bar(stat="identity",
           position=position_dodge()) +
  geom_errorbar(aes(ymin=Hits,
                    ymax=Hits+STD),
                width=0.2)+
  theme_classic()
hits

enter image description here

Cheers!

Phil
  • 7,287
  • 3
  • 36
  • 66
vschultzx
  • 1
  • 2
  • 1
    Without your data, we can't know for sure, but it looks as though you have several rows for each Phenotype. You get one bar and one error bar for each row of your data. You can't see the bars because they are plotted over each other, so you only see the tallest one. However, you can easily see the error bars stacked on top of each other. It seems to me that you need to sumarize your data, perhaps grouping by phenotype and taking the average of `Hits`. Better still, forget the bars and use a boxplot or violin plot to show your data more appropriately. – Allan Cameron Dec 22 '22 at 14:29
  • hi @AllanCameron yes I have 36 samples, 4 different phenotypes. i couldn't find a way to merge each sample to assigned phenotype. and yes, it gives error bars to each sample.. i'm trying to average now! thanks for suggestion. – vschultzx Dec 22 '22 at 14:55

0 Answers0