[R] panel.groups: use group.number to define colors
baptiste auguie
ba208 at exeter.ac.uk
Tue Oct 7 17:54:19 CEST 2008
Dear list,
I've been trying this for a few hours and I just don't understand how
lattice works with groups and subscripts.
Consider the following example,
> xx <- seq(1, 10, length=100)
> x <- rep(xx, 4)
> y <- c(cos(xx), sin(xx), xx, xx^2/10)
> fact <- factor(rep(c("cos", "sin", "id", "square"), each=100))
> fact2 <- factor(rep(c("periodic", "not periodic"), each=100))
>
> my.df <- data.frame(x=x, y=y, fact = fact, fact2 = fact2)
>
> head(my.df)
>
>
> myColors <- c(2, 4)
>
> xyplot(y ~ x | fact, data = my.df, groups = fact2,
> panel = panel.superpose,
> panel.groups = function(..., group.number) {
>
> panel.xyplot(...)
> #panel.xyplot( ..., col=myColors[group.number]) # error
>
> })
My aim is to assign a custom color to each group, but for some reason
the col parameter is already given to panel.xyplot and I can't find
where it gets the values from.
Many thanks,
baptiste
_____________________________
Baptiste Auguié
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
More information about the R-help
mailing list