Skip to content

ggplot2's geom_errorbar legend

4 messages · Giovanni Azua, Ista Zahn, Hadley Wickham

#
Hello,

I create a simple ggplot that only shows a straight line. I then add three datasets of CI using the geom_errorbar function. The problem is that I can't find any way to have the legend showing up ... I need to show what each  color of the CIs corresponds to i.e. which method. 

Can anyone advice please?
TIA,
Best regards,
Giovanni
#
Hi Giovanni,
A reproducible example would help. Also, since I think this will be
tricky, it might be a good idea to post it to the ggplot2 mailing list
 (you can register at http://had.co.nz/ggplot2/ ).

Best,
Ista
On Sat, May 1, 2010 at 1:34 PM, Giovanni Azua <bravegag at gmail.com> wrote:

  
    
3 days later
#
Hi Giovanni,

The basic idea is:

classiclimits <- aes(x=x[1:100],ymax = classiccis[1:100,e,p,
 ymin=classiccis[1:100,e,p,2], colour = "classic")
ownlimits <- aes(x=x[1:100]+0.4,ymax = owncis[1:100,e,p,1],
  ymin=owncis[1:100,e,p,2], colour = "own")
rbootlimits <- aes(x=x[1:100]+0.8,ymax = rbootcis[1:100,e,p,1],
  ymin=rbootcis[1:100,e,p,2], colour = "rboot")

And then remove the explicit colours elsewhere in your code.

Hadley