[R] coloring individual points in lattice xyplot

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed 05 Jul 2006 - 01:42:14 EST

If I wish to color groups in xyplot I can do this:

   x <- 1:10
   y <- cbind(x, x+1)
   xyplot(y ~ rep(x,2), group = col(y), col = 1:2)

How do I color different points differently within a group.

For example, I want to produce this plot (except that I only want to have two groups, not 11):

   xyplot(y ~ rep(x,2), group = c(rep(1, 10), 2:11), col = 1:11)

I am thinking of something like this (although this does not work, its just to get the idea across):

   xyplot(y ~ rep(x,2), group = col(y), col = list(1, 2:11))

where, in general, I have a list with one component per group whose elements are scalars to color the whole group or vectors one color per point in the group. I don't know ahead of time what the list is.

I am looking for a general approach to this within the lattice xyplot plot framework; the above is just an example.

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 Wed Jul 05 01:46:25 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 05 Jul 2006 - 06:16:16 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.