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

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to