0

I'm trying to put the errobars in my plot, but I end up with this

library(ggplot2)
ggplot(carotenoids, aes(fill=sex, y=carotenoid, x=treatment)) + 
  geom_bar(position="dodge", stat="identity") + 
  geom_errorbar( aes(x=sex, ymin=carotenoid-sd(carotenoids), ymax=carotenoid+sd(carotenoids)))+
  facet_grid(~ sampling)

This is my data

  sampling treatment sex N      mean        sd        se
1        T1        AL   f 3 136.41929 41.865698 24.171172
2        T1        AL   m 3  63.57695 21.109343 12.187485
3        T1        AN   f 3 118.47484 18.441576 10.647249
4        T1        AN   m 1 107.64238        NA        NA
5        T1        VG   f 3  97.71919 18.494844 10.678003
6        T1        VG   m 2  62.96120  6.481925  4.583413
7        T2        AL   f 3  18.08122  2.830274  1.634060
8        T2        AL   m 3  27.32499 15.547590  8.976405
9        T2        AN   f 3  44.60480 16.768462  9.681276
10       T2        AN   m 3  26.70155 18.734837 10.816563
11       T2        VG   f 3  39.89797  6.120367  3.533596
12       T2        VG   m 3  32.82375 16.927051  9.772837
A. Suliman
  • 12,923
  • 5
  • 24
  • 37
  • Hi, it's not completely clear what the behaviour is now and what the behaviour should be and if there are any errors. – Owl Feb 06 '20 at 10:54
  • Please provide a dummy data in `dput()` format. – UseR10085 Feb 06 '20 at 11:15
  • I still can´t do it... – Andreia Raposo Feb 06 '20 at 11:17
  • It's difficult to help without reproducible data but try to replace `geom_errorbar` with `geom_errorbar( aes(x=treatment, ymin=carotenoid-sd(carotenoids), ymax=carotenoid+sd(carotenoids)), position = position_dodge(width = 0.90),width=0.25, stat = "identity")`. Welcome to SO, please see [how-do-comment-replies-work](https://meta.stackexchange.com/questions/43019/how-do-comment-replies-work) – A. Suliman Feb 06 '20 at 11:27
  • @A.Suliman I´ve tried but it is not right...the errosbar are in the right place but it seems that there is more than one errobar in the same bar... – Andreia Raposo Feb 06 '20 at 11:54

0 Answers0