[R] Use of panel.segments
Lancaster, Vicki
Vicki.Lancaster at fda.hhs.gov
Tue Feb 15 17:14:36 CET 2011
First I have read all the previous post on error bars & segments as well as the Lattice book by Sarkar.
I am using xyplot, there are 2 panels, each panel displays the measurements from 5 matrices over time. The matrices are identified by different colors. My error bars show up in the 1st panel and not the second. Any suggestions would be greatly appreciated the code follows - thanks.
#Figure 2
data2$Type<-ordered(data2$Type, c("SDM","AcSDM"))
sub2<-table(data2$Matrix, data2$Type)
fill.palette2<-c(rep(palette2, sub2[,1]), rep(palette2, sub2[,2]))
subscripts2<-1:dim(data2)[1]
#Figure 2
xyplot(Response~Time|Type, data=data2, upper=log10(data2$Response+data2$SD),
lower=log10(data2$Response-data2$SD),
groups=fill.palette2, cex=1.35, layout=c(2, 1), type=c("p","g"), col="black", aspect=1, col.line="light grey", lty=8, xlim=c(30, 120),
scales=list(x=list(at=seq(from=30, to=120, by=20)), y=list(log=10)),
ylab="Concentration in Matrices (ppb)",
xlab="Time after last dose (hour)",
main="Figure 2. Depletion for Average Concentration by Matrix over Time
(Length of the black vertical line is two standard deviations)",
panel=function(x, y, groups, subscripts, upper, lower, ...){
panel.xyplot(x, y, pch=21, fill=groups[subscripts2], ...)
panel.abline(v=100, col="black", lty=8)
panel.text(110, log10(55000), "Post-mortem", cex=0.7)
panel.text(110, log10(40000), "Measurements", cex=0.7)
switch(panel.number()
panel.segments(x[subscripts], lower[subscripts],
x[subscripts], upper[subscripts], lty=1, col="black")},
key=list(corner=c(0.02, 0.04), text=list(levels(data2$Matrix)),
cex=0.75, columns=1,border=TRUE,
points=list(pch=c(21, 21, 21, 21, 21), fill=palette2, cex=c(1.5, 1.5, 1.5, 1.5, 1.5)))
)
More information about the R-help
mailing list