Description Usage Arguments Details See Also Examples
When generating multipanel figures, automatically determines arguments to par(mfrow=c(x,y))
that use space most efficiently, finding the balance between minimizing empty panels and achieving square panel dimensions.
1 | auto.mfrow(x, tall = FALSE)
|
x |
numeric, the number of panels |
tall |
logical, if FALSE (the default), non-square panel arrangements will have more columns than rows (e.g., |
auto.mfrow
will often produce figures with "empty" panels - auto.mfrow
does not (necessarily) find dimenions suitable for publication, as for prime numbers this would often lead to 1-by-X or X-by-1 dimensions that would run off the screen/ page when x
was large, which auto.mfrow
avoids by permitting ampty panels. The ideal balance between non-square panel dimenions and empty panels is subjective, but the dimensions are found by the values of nr
and nc
that minimize the following expression: abs(sqrt(x)-(nr)) + abs(sqrt(x)-(nc)) + abs(nr*nc-x)
, with output switching between nr-by-nc and nc-by-nr depending on the value of tall
).
See rbLib-package
for package overview.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | N <- 5
par(mfrow=auto.mfrow(N))
for(i in 1:N){plot(1:i)}
# Example also showing number of panels given number of plots
panels <- c()
empty <- c()
for(i in 1:25){
panels[i] <- prod(auto.mfrow(i))
empty[i] <- panels[i] - i
}
par(mfrow=auto.mfrow(2, tall=TRUE), mar=c(2.5,2.5,0.25,0.25), mgp=c(1.15,0.25, 0), tcl=-0.15, ps=10)
plot(panels, xlab="Number of plots", ylab="number of panels")
abline(a=0,b=1)
plot(empty, xlab="Number of plots", ylab="number of empty panels", type="o")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.