[R] Problem with bwplot and panel.abline

W. C. Thacker Carlisle.Thacker at noaa.gov
Mon Apr 19 16:20:43 CEST 2004


When plotting box & whisker plots to show the distributions of
residuals of several models, it would be useful to add a vertical line
to indicate zero residuals.  By adding an explicit panel function that
includes panel.abline and panel.bwplot, it is possible to get the
vertical line, but the median is no longer indicated.

The problem seems to be with panel.bwplot ---  omitting panel.abline
does not restore the median indicator.  Adding pch=16 explicitly as an
argument to panel.bwplot does restore the dot, but in a strange color
(yellow).  Adding col="black" explicitly as an argument to
panel.bwplot makes the background black.

Any suggestions would be highly appreciated.

platform sparc-sun-solaris2.9
arch     sparc               
os       solaris2.9          
system   sparc, solaris2.9   
status                       
major    1                   
minor    8.0                 
year     2003                
month    10                  
day      08                  
language R                   

> rlm1.residuals[1,]
   p      rlm1
1 25 0.1878673

postscript(file="bw.residual.verification.eps",horizontal=F,paper="letter")
trellispar <- trellis.par.get("plot.symbol")
trellispar$pch <- "."
trellis.par.set("plot.symbol",trellispar)
trellispar <- trellis.par.get("box.dot")
trellispar$cex <- 0.4
trellispar$col <- "black"
trellis.par.set("box.dot",trellispar)
trellispar <- trellis.par.get("box.umbrella")
trellispar$lty <- 1
trellis.par.set("box.umbrella",trellispar)
bwplot(-p~rlm1,
    data=rlm1.residuals,
as.table=TRUE,
panel = function(x,y,subscripts,...){
        panel.abline(v=0,lty=3,lwd=1,col="red")
        panel.bwplot(x,y,subscripts,pch=16,...)},
scales=list(x=list(cex=0.7),
            y=list(tick.number=length(where),
                            at=length(where):1,
                         labels=format(where),
                            cex=0.7)),
 xlab = "measured salinity - estimated salinity (psu)",
 ylab = "pressure (dbar)",
  sub = list("lm(s~t+I(t^2))",font=1),
main=list(paste(format(length(unique(P0.verification$id))),
"verification profiles"),font=1))
dev.off()

Thanks,

Carlisle

William Carlisle Thacker                            
                                                    
Atlantic Oceanographic and Meteorological Laboratory
4301 Rickenbacker Causeway, Miami, Florida 33149 USA
Office: (305) 361-4323           Fax: (305) 361-4392

"Too many have dispensed with generosity 
     in order to practice charity."     Albert Camus




More information about the R-help mailing list