Skip to content
Back to formatted view

Raw Message

Message-ID: <48D4F38D.80809@vanderbilt.edu>
Date: 2008-09-20T12:58:53Z
From: Frank E Harrell Jr
Subject: Coloring spaces between lines in xyplot
In-Reply-To: <48D4DB4F.9000601@bitwrit.com.au>

Jim Lemon wrote:
> Seth W Bigelow wrote:
>> Ok, thanks to Carl Witthoft I now know that to color spaces between  and
>> below a pair of lines in xyplot, I will need to redefine the lines as
>> polygons, and use the lpolygon panel function, as in the following
>>
>> library(lattice)
>> p <- c(1,10,10,1)       #  vector of x values
>> q <- c(4,29.2,16,2.5)          # vector of y values for upper polygon
>> r <- c(2.5,16,0,0)                    # vector of y values for lower
>> polygon
>>
>> xyplot(
>>   q + r ~ p,
>>   panel = lpolygon,
>>   col = c("red","green")
>>   )
>>
>> But, having spent several hours arriving at this increment of knowlege, I
>> find myself stumped at how to assign different colors to the two 
>> polygons!
>> the above "col" line did not do the job.
>>
>>   
> Hi Seth,
> Maybe you could use the stackpoly function in the plotrix package:
> 
> x<-matrix(x,nrow=10)
> y<-matrix(y,nrow=10)
> stackpoly(x,y,stack=TRUE)
> 
> Jim

Also see the filled bands option in the xYplot function in the Hmisc 
package.
Frank


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University