The objective is to have a barchart where the bars are filled with
a color depending on a group membership, but I haven't been
able to get it to work. I get coloring that doesn't correspond
to my groups. Here's the function; any help is appreciated.
panel.barchart.superpose <- function(x, y, groups, ...)
{
ok <- !is.na(x) & !is.na(y)
x <- x[ok]
y <- y[ok]
y1 <- y - 1/3
y2 <- y + 1/3
n <- length(y)
xmin <- rep(par("usr")[1], n)
NAs <- rep(NA, n)
groups <- as.numeric(as.factor(groups[ok]))
max.groups <- max(groups)
if (is.null(col)) {
col <- rep(trellis.par.get('superpose.symbol')$col,
length=max.groups)
} else {
col <- rep(col,length=max.groups)
}
N <- seq(along=groups)
for (i in sort(unique(groups))) {
j <- N[groups == i]
polygon(c(rbind(xmin[j], x[j], x[j], xmin[j],NAs[j])),
c(rbind(y1[j], y1[j], y2[j], y2[j], NAs[j])),
col = col[i], border = 1)
}
}
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news