[R] Superimpose Histograms

Andreas Wilm wilm at biophys.uni-duesseldorf.de
Wed Nov 30 01:39:20 CET 2005


> library(R.basic)
> example(plot.histogram)
> 
>  x1 <- rnorm(1000,  0.4, 0.8)
>  x2 <- rnorm(1000,  0.0, 1.0)
>  x3 <- rnorm(1000, -1.0, 1.0)
>  hist(x1, width=0.33, offset=0.00, col="blue", xlim=c(-4,4),
>       main="Histogram of x1, x2 & x3",
>       xlab="x1 - blue, x2 - red, x3 - green")
>  hist(x2, width=0.33, offset=0.33, col="red", add=TRUE)
>  hist(x3, width=0.33, offset=0.66, col="green", add=TRUE)
> 
> It overloads the default plot.histogram() (called when you do hist()) so
> it takes arguments 'offset' and 'width' too.


Great! That's what I was lookin for.
Thanks Henrik.

Andreas


-- 

Andreas Wilm

Institut fuer Physikalische Biologie
Heinrich-Heine-Universitaet Duesseldorf
http://www.biophys.uni-duesseldorf.de

E-Mail: wilm at biophys.uni-duesseldorf.de / 0x7C68FBCC
Phone:  +49 211 8115966




More information about the R-help mailing list