[R] ggplot2: How to remove legend component for geom_errorbar() ?

From: Carsten Jaeger <cajaeg_at_googlemail.com>
Date: Mon, 16 Jun 2008 09:55:55 +0200


Dear list (probably Hadley),

I'm trying to do a plot like the following, composed of bars and error bars:

df <- data.frame(factor1=gl(2,5), factor2=gl(5,1), y=rnorm(10), err=0.1)
ggplot(df, aes(x=factor1, y=y, fill=factor2)) +

    geom_bar(position="dodge", stat="identity") +     geom_errorbar(aes(min=y-err, max=y+err), position="dodge", width=0.1)

The plot obtained has a legend named "factor2", giving as expected the colours used for the five factor levels of factor2. So far so good. However, the legend also contains solid horizontal lines, obviously representing the error bars. While I do not immediately see the sense of a legend symbol for error bars, is there any easy way to turn these off?

Thanks,
Carsten



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 16 Jun 2008 - 10:51:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 16 Jun 2008 - 15:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive