[R] Legend issue with ggplot2
ONKELINX, Thierry
Thierry.ONKELINX at inbo.be
Mon Sep 3 12:12:53 CEST 2007
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))
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))
Thanks,
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
Thierry.Onkelinx op inbo.be
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
More information about the R-help
mailing list