Hi Dieter:

I think the OP wanted both lines and shading; from your code I could get the
shading but not the lines. This is what it took for me to get the lines
(note the type and col.line changes in xyplot() ):

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 = 'r',
 col = 'gray80', col.line = c('red', 'blue'),
 upper = data$upper,
 lower = data$lower,
 panel = function(x, y, ...){
    panel.superpose(x, y, panel.groups = 'panel.bands',...)
    panel.xyplot(x, y, ...)
   })

But this creates a new problem...the lines extend farther than the bands. I
was trying to find the lattice equivalent of xaxs = 'i' but couldn't, so
I'll throw it up for grabs - either the lines get clipped to the bandwidth
or the bands get extended to the limits of the horizontal plot region.

Dennis

On Wed, Oct 20, 2010 at 12:05 AM, Dieter Menne <dieter.me...@menne-biomed.de
> wrote:

>
>
> 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.
>
> ______________________________________________
> 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.
>

        [[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.

Reply via email to