[R] 2 bwplots - different colors

Martina Pavlicova pavlicov at stat.ohio-state.edu
Mon Feb 16 17:37:27 CET 2004


Hi all,

I would like to draw one picture which would show two different types of
boxplots using the same axes (kind of on top of each other). However, I
would like to plot each boxplot using a different color or different
shading inside the box, so they could be better distinquished from each
other... Could you help me?

Here is an example of the plot I have so far. I was only able to change
the color the median-dot (to 'red').

library(lattice)
foo1 <- matrix(rnorm(600),30,20)
foo2 <- matrix(rchisq(600,3),30,20)
bwplot(t(foo1)~c(1:20), xlim=as.character(seq(.01, .2, by=.01)),
       horizontal=F, bty=n, ylim=c(-3,11),
       panel=function(x,y,axes=F,...){
         panel.bwplot(x,y,bty=n,...)
         panel.bwplot(x, foo2, bty=n, col="red", ...)
       }
       )

Thank you very much for your help.

Martina Pavlicova

--------------------------------------------------------------------------
Department of Statistics             Office Phone: (614) 292-1567
1958 Neil Avenue, 304E Cockins Hall  FAX: (614) 292-2096
The Ohio State University            E-mail: pavlicov at stat.ohio-state.edu
Columbus, OH 43210-1247              www.stat.ohio-state.edu/~pavlicov




More information about the R-help mailing list