Re: [R] lattice legend colors recycling sooner than expected

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Sat 10 Dec 2005 - 04:19:31 EST

On 12/9/05, alejandro munoz <guerinche@gmail.com> wrote:
> dear r-helpers,
>
> it seems the colors in an automatically generated lattice legend
> recycle after the 8th color, even when the user has set e.g.
> superpose.symbol$col to be longer than 8. the following example will
> illustrate what i mean:
>
> z <- data.frame(x=rep(letters[1:15], each=4), y=rnorm(60),
> groups=rep(LETTERS[1:3], 20))
> library(nlme)
> library(lattice)
> plot(groupedData(y ~ x | groups, data=z))
> # symbol colors recycle after every 8 for plot and legend symbols;
> # e.g. a, h, and o are cyan.
>
> trellis.par.set(superpose.symbol = list(col=rainbow(15)))
> plot(groupedData(y ~ x | groups, data=z))
> # each dot in the plot has a different color, but colors in legend
> # still recycle every 8 points; e.g. cyan, violet, and blue aren't in
> legend.
>
> in case this is an nlme issue, i examined the three
> plot.XXXGroupedData methods, but could not find any obvious fixes.

It is indeed an nlme issue, although I'm not yet sure how.

> is there a simple way of having auto.key "know" how many color entries
> it should have?

'auto.key' does know; at least for me

dotplot(groups ~ y, groups = x, data=z, auto.key = list(space = "right"))

uses the correct colors. The problem is that nlme (which was written before lattice existed) doesn't use 'auto.key'. It could have been updated after the fact, but in the spirit of "don't fix it if it ain't broken", I haven't mucked around with it unless necessary. I'll look into it.

Deepayan



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 Received on Sat Dec 10 04:30:46 2005

This archive was generated by hypermail 2.1.8 : Sat 10 Dec 2005 - 09:32:16 EST