[R] Multiple hist(ograms) - One plot

Dieter Menne dieter.menne at menne-biomed.de
Thu Oct 2 08:56:01 CEST 2008


Michael Just <mgjust <at> gmail.com> writes:

> I am trying to plot multiple histograms with the same scales, etc into one
> plot. The commands below produce a 3 page PDF with each histogram occupying
> the upper right quadrant. And use slightly different scales on the X and Y
> axes.

I suggest that you forget hist (="old style" graphics) for this type of job and
use trellis graphics in package lattice, function histogram instead. True,
lattice has a bit of a learning curve, but I promise you it pays. No manual
subset selection, and "same scaling" is the default; you will even have some
problems when you want to force different scaling.

See http://dsarkar.fhcrc.org/lattice/book/figures.html

You could also have a look a ggplot2, which takes and elegant approach, but
still has a few rough edges.

Dieter



More information about the R-help mailing list