[R] 49 histograms on one page
Sundar Dorai-Raj
sundar.dorai-raj at pdf.com
Mon Feb 21 20:02:01 CET 2005
Christian Hennig wrote:
> Hi,
>
> I want to do something like this:
>
> par(mfrow=c(7,7))
> for (i in 1:49)
> hist(RATDACOM[SUBJNO==i],breaks=0.5+(0:6),
> main="",xlab="",ylab="",xaxt="n",yaxt="n")
>
> (Don't think about what RATDACOM and SUBJNO are.)
>
> I get an error
> Error in plot.new() : Figure margins too large.
>
> 36 histograms with mfrow=c(6,6) work.
> But the 36 histograms are then so small that I wonder why 49 do not fit.
> It seems that though I have main="",xlab="",ylab="",xaxt="n",yaxt="n" the
> area reserved for axes and labels is almost as large as it would be if I
> would print a single histogram. The histogram itself only gets the remaining
> space, which is very small (I could draw 36*4 histograms of this size on a
> single page and the margins between them would still be OK).
>
> So the question is:
> How do I tell R to print the essential histogram area without main, labs and
> axes large enough that it looks well but small enough that 49 fit on one
> page? (If I would draw them by hand, no problem...)
>
> Best,
> Christian
>
You may want to look at ?histogram in package:lattice.
set.seed(1)
m <- 100
n <- 49
RATDACOM <- rnorm(m * n)
SUBJNO <- rep(seq(n), each = m)
histogram(~ RATDACOM | SUBJNO,
layout = c(7, 7),
strip = FALSE)
--sundar
More information about the R-help
mailing list