Thanks Hadley, I've been struggling with this all afternoon. But now it's working again. Since I'm using it in a script, the few extra lines don't bother me that much.
Thierry ------------------------------------------------------------------------ ---- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney > -----Oorspronkelijk bericht----- > Van: hadley wickham [mailto:[EMAIL PROTECTED] > Verzonden: maandag 3 september 2007 15:15 > Aan: ONKELINX, Thierry > CC: [email protected] > Onderwerp: Re: [R] Legend issue with ggplot2 > > On 9/3/07, ONKELINX, Thierry <[EMAIL PROTECTED]> wrote: > > Dear useRs, > > > > I'm struggling with the new version of ggplot2. In the previous > > version I did something like this. But now this yield an > error (object "fill" > > not found). > > > > library(ggplot2) > > dummy <- data.frame(x = rep(1:10, 4), group = gl(4, 10)) dummy$y <- > > dummy$x * rnorm(4)[dummy$group] + 5 * rnorm(4)[dummy$group] > dummy$min > > <- dummy$y - 5 dummy$max <- dummy$y + 5 ggplot(data = > dummy, aes(x = > > x, max = max, min = min, fill = group)) + > > geom_ribbon() + geom_line(aes(y = max, colour = fill)) + > > geom_line(aes(y = min, colour = fill)) > > Strange - I'm not sure why that ever worked. > > > When I adjust the code to the line below, it works again. But this > > time with two legend keys for "group". Any idea how to display only > > one legend key for group? The ggplot-code aboved yielded > only on legend key. > > > > ggplot(data = dummy, aes(x = x, max = max, min = min, > colour = group, > > fill = group)) + geom_ribbon() + geom_line(aes(y = max)) + > > geom_line(aes(y = min)) > > You can manually turn off one of the legends: > > sc <- scale_colour_discrete() > sc$legend <- FALSE > .last_plot + sc > > It's not very convenient though, so I'll think about how to > do this automatically. The legends need to be more > intelligent about only displaying the minimum necessary. > > Hadley > ______________________________________________ [email protected] 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.
