[R] superpose.polygon, panel.polygon and their colors
Dieter Menne
dieter.menne at menne-biomed.de
Wed Oct 20 09:05:26 CEST 2010
Ottorino-Luca Pantani wrote:
>
> Thanks Dieter for your help, but unfortunately your suggestion results
> only in changing the color of the *lines* and not the color of the
> *area* of the polygon.
>
>
The following complete code works for me. Do you have the current version
of lattice/R installed?
# polygon color
library(lattice)
est <- c(1:4, 3:6, 7, 9, 11, 13, 12, 15, 18, 21)
cond <- rep(c('a','b'), each = 8)
grp <- rep(c('I', 'II'), each = 4, 2)
x <- rep(c(.5, .7, .9, 1.1), 4)
upper <- est + 1
lower <- est - 1
data <- data.frame(est = est, x = x, cond = cond, grp = grp, upper =
upper, lower = lower)
rm(est, cond, grp, x, upper,lower)
panel.bands <- function(x, y, upper, lower,
subscripts, ..., font, fontface) {
upper <- upper[subscripts]
lower <- lower[subscripts]
panel.polygon(c(x, rev(x)), c(upper, rev(lower)),...)
}
xyplot(est ~ x | cond, group = grp, data = data, type = 'b',
col="gray",
upper = data$upper,
lower = data$lower,
panel = function(x, y, ...){
panel.superpose(x, y, panel.groups = 'panel.bands',...)
panel.xyplot(x, y, ...)
})
--
View this message in context: http://r.789695.n4.nabble.com/superpose-polygon-panel-polygon-and-their-colors-tp3002374p3003362.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list