[R] lattice xyplot strip colors and location

Ajay, Shankar Ajay (NIH/NHGRI) [F] ajayss at mail.nih.gov
Thu Aug 20 04:23:30 CEST 2009


Hi all, 

I've been trying (unsuccessfully) to modify an xyplot I created using the lattice package. I would like to change default strip colors and locations. 
I started with numeric data in 4 columns, which look like this:

0.25    2       1       32
0.25    2       2       30
0.25    2       3       27
0.25    2       4       23
0.25    2       5       17
0.25    3       1       30
0.25    3       2       29
0.25    3       3       26
0.25    3       4       21
0.25    3       5       15
0.5     2       1       23
0.5     2       2       23
0.5     2       3       22
0.5     2       4       18
0.5     2       5       15
0.5     3       1       22
0.5     3       2       22
0.5     3       3       21
0.5     3       4       16
0.5     3       5       13

Here's what I've done so far:

library(lattice)
plotdata <- read.table(file="data.txt", header=FALSE)

attach(plotdata)

frac.f <- factor(V1)
stdev.f <- factor(V2)
levels(frac.f) <- paste("f=",levels(frac.f), sep="")
levels(stdev.f) <- paste("s=", levels(stdev.f), sep="")
xyplot(V4~V3|frac.f*stdev.f, aspect=3/4, xlab="Reads as evidence", ylab="Total incorrect")
detach(plotdata)

Conditional variable values now appear as two stacked strips at the top of each panel. I'd like to move one to the left and also change strip colors.

I tried the following but it didn't produce the desired result

xyplot(V4~V3|frac.f*stdev.f, aspect=3/4, xlab="Min number of reads", ylab="Number of misjoins", strip=strip.custom(which.given=1, bg="skyblue"), strip.left=strip.custom(which.given=2,bg="yellow"))

This changes the colors but also does the following 
- positions the left strips slightly away from the respective panels
- all strip labels and values reflect only one conditional variable (s=2, s=3, etc.)

Any help would be much appreciated

Thanks,
Shankar

Postdoctoral Fellow
National Human Genome Research Institute
NIH 
Bethesda, MD



More information about the R-help mailing list