Learn R Programming

fifer (version 1.1)

auto.layout: Automatically select the layout.

Description

Given a particular number of plots, auto.layout will automatically determine the arrangement of each plot using the layout function. See examples.

Usage

auto.layout(n, layout = T)

Arguments

n
the number of plots
layout
should the fuction return a preallocated layout object? If FALSE, it returns a matrix

Value

either a matrix or a layout object

Examples

Run this code
## plot six plots
auto.layout(6)
for (i in 1:6){
	plot(rnorm(100), rnorm(100))	
}
## same as mar(mfrow=c(3,2))
par(mfrow=c(3,2))
for (i in 1:6){
	plot(rnorm(100), rnorm(100))	
}
## default for odd number of plots using mfrow looks terrible
par(mfrow=c(3,2))
for (i in 1:5){
	plot(rnorm(100), rnorm(100))	
}
## much better with auto.layout
auto.layout(5)
for (i in 1:5){
	plot(rnorm(100), rnorm(100))	
}

Run the code above in your browser using DataLab