1

I have made a graph using ggplot from data I transformed into means with code:

I would like to know if there is anyway I can add error bars to this graph. I know I have to transform the data to have more summaries but not sure how to proceed. Tried to do it seperately for each column but could'nt make a graph from it. like this:

Temperature <- ddply(shlf, c("Location"), summarise,
                       N = length(temp),
                       mean.temp = mean(temp),
                       sd = sd(temp),
                       se = sd / sqrt(N))

Any help is appreciated.

1
  • 1
    Please use dput(means) so that everyone can have your exact data.frame without having to copy it number by number (or to invent fake data). Commented Oct 22, 2016 at 11:11

1 Answer 1

3

You are almost there. This is based on se as provided in Temperature data:

means$upper = Temperature$mean.temp + Temperature$se
means$lower = Temperature$mean.temp - Temperature$se

ggplot(means, aes(x = temp,
                  y = Triconia,
                  color = Location)) +
   geom_point(size = 5.0) +
   geom_errorbarh(aes(xmin = upper, xmax = lower))

Errorbar as a separate geom comes in distinct flavors: geom_errorbar is vertical and geom_errorbarh is horizontal; there are also things like geom_crossbar, geom_pointrange and the like. See ?geom_errorbar for help and some examples on all of them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.