# Setup x1 <- rnorm(100) x2 <- rnorm(100, mean=5) # Graphics hist(c(x1,x2)) xrange<-range(x1,x2) h1 <- hist(x1, breaks=(seq(floor(xrange[1]), ceiling(xrange[2]))), plot=F) h2 <- hist(x2, breaks=(seq(floor(xrange[1]), ceiling(xrange[2]))), plot=F) yrange <- c(0,range(h1$counts,h2$counts)[2]) plot(h1, xlim=xrange, ylim=yrange, col="blue") par(new=T) plot(h2, xlim=xrange, ylim=yrange) par(new=F) opar <- par(mfrow=c(2,2)) plot(h1); plot(h2) plot(h1, xlim=xrange, ylim=yrange, col="blue") plot(h2, xlim=xrange, ylim=yrange) par(opar) # Lattice dfx1 <- data.frame(x=x1, source="x1") dfx2 <- data.frame(x=x2, source="x2") df <- rbind(dfx1, dfx2) library(lattice) histogram(~x, data=df) histogram( ~x, data=df, layout=c(1,2)) histogram(~x | source, data=df, scales=list(alternating=FALSE))