Apologies once more, there was a slight error in our example. Here is a correct version of how to color the points in qqmath according to another variable.
qqmath(~ yield | variety, data = barley, groups=year, auto.key=TRUE, prepanel = function(x, ...) { list(xlim = range(qnorm(ppoints(length(x))))) }, panel = function(x, ...) { qx <- qnorm(ppoints(length(x)))[rank(x)] panel.xyplot(qx, x, ...) }) Kevin On Wed, May 27, 2009 at 4:39 PM, Kevin W <kw.st...@gmail.com> wrote: > Thanks to Deepayan, I have a corrected version of how to color points in a > qqmath plot according to another variable. Using the barley data for a more > concise example:: > > qqmath(~ yield | variety, data = barley, groups=year, > auto.key=TRUE, > prepanel = function(x, ...) { > list(xlim = range(qnorm(ppoints(length(x))))) > }, > panel = function(x, ...) { > xx <- qnorm(ppoints(length(x)))[order(x)] > panel.xyplot(x = xx, y = x, ...) > }) > > > The example I posted previously (and shown below) is not correct. My > apologies. > > Kevin > > > On Wed, May 27, 2009 at 11:05 AM, Kevin W <kw.st...@gmail.com> wrote: > >> Having solved this problem, I am posting this so that the next time I >> search for how to do this I will find an answer... >> >> Using qqmath(..., groups=num) creates a separate qq distribution for each >> group (within a panel). Using the 'col' or 'pch' argument does not >> (usually) work because panel.qqmath sorts the data (but not 'col' or 'pch') >> before plotting. Sorting the data before calling qqmath will ensure that >> the sorting does not change the order of the data. >> >> For example, to obtain one distribution per voice part and color the point >> by part 1 or part 2: >> >> library(lattice) >> singer <- singer >> singer <- singer[order(singer$height),] >> singer$part <- factor(sapply(strsplit(as.character(singer$voice.part), >> split = " "), "[", 1), >> levels = c("Bass", "Tenor", "Alto", "Soprano")) >> singer$num <- factor(sapply(strsplit(as.character(singer$voice.part), >> split = " "), "[", 2)) >> qqmath(~ height | part, data = singer, >> col=singer$num, >> layout=c(4,1)) >> >> >> >> Kevin >> >> > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.