[R] help change auto.key colors in xyplot
h.wickham at gmail.com
Fri Feb 13 22:52:30 CET 2009
On Fri, Feb 13, 2009 at 1:22 PM, Dieter Menne
<dieter.menne at menne-biomed.de> wrote:
> Dimitri Liakhovitski <ld7631 <at> gmail.com> writes:
>> the code below works just fine to produce a dotplot. However, I am not
>> successful changing the color of the lines in the legend (auto.key).
>> If I add col=..., it only changes the color of the letters in the
>> legend, but not the color of the lines.
> I prefer to set pch and friends outside the panel function to
> avoid clutter, and to set the parameters globally, thus forcing
> my plots to be similar. This is a matter of taste, though.
> On Windows, the key looks a bit ugly now.
> Group 1 o ----
> 2 o-----
> I am not very happy that the lwd is not honored by the key.
> Lines in lwd 2 (plot) and in lwd 1 (default key) do have a quite
> different subjective color hue. Any way around this, Deepayan?
> (Besides using ggplot2, as Hadley would argue ??)
And here is a ggplot2 solution ;)
df <- data.frame(
x = rep(d[], 2),
y = c(d[], d[]),
group = rep(c("Group 1", "Group 2"), each = 3)
ggplot(df, aes(x, y, group = group)) +
geom_point(aes(colour = group), size = 3) +
geom_line(aes(colour = group), size = 1.5) +
geom_text(aes(label = y, y = y + 0.02), vjust = 0, size = 4)
The legends are pretty good at figuring out exactly what should be
displayed, based on what you've used in the graphic.
More information about the R-help