Learn R Programming

cwhmisc (version 6.0)

mult.fig.p: Plot Setup for multiple plot, incl. main title

Description

Easy Setup for plotting multiple figures (in a rectangular layout) on one page. It allows to specify a main title, a bottom line, and uses smart defaults for several par calls.

Usage

mult.fig.p(nr.plots, mfrow, mfcol, marP = rep(0, 4), mgp = c(1.5, 0.6, 0), mar = marP + 0.1 + c(4, 4, 2, 1), main = NULL, sub = NULL, adj.sub = 0.5, tit.wid = if (is.null(main)) 0 else 1 + 1.5*cex.main, quiet = .Device == "postscript", cex.main = par("cex.main"), col.main = par("col.main"), font.main = par("font.main"), ...)

Arguments

nr.plots
integer; the number of plot figures you'll want to draw.
mfrow
instead of nr.plots: integer(2) vector giving the rectangular figure layout for par(mfrow= .)
mfcol
instead of nr.plots: integer(2) vector giving the rectangular figure layout for par(mfcol= .)
marP
numeric(4) vector of figure margins to add (``Plus'') to default mar, see below.
mgp
argument for par(mpg= .) with a smaller default than usual.
mar
argument for par(mar= .) with a smaller default than usual, using the marP argument, see above.
main
character. The main title to be used for the whole graphic.
sub
character. The bottom line to be used for the whole graphic.
adj.sub
The value of adj determines the way in which sub is justified. A value of 0 produces left-justified text, 0.5 centered text and 1 right-justified text. See par(adj= .)
tit.wid
numeric; the vertical width to be used for the main title.
quiet
Suppress request to restore graphical parameters.
cex.main
numeric; the character size to be used for the main title.
col.main
string; name of the color to be used for the main title.
font.main
numeric; number of the font to be used for the main title.
...
Further arguments to mtext for main and sub.

Value

A list with two components that are lists themselves, a subset of par(),
new.par
the current par settings.
old.par
the par before the call.

See Also

par, layout.

Examples

Run this code
AA <- mult.fig.p(5, main= "Sine functions of different frequencies")
x <- seq(0, 1, len = 201)
for (n in 1:5)
  plot(x, sin(n * pi * x), ylab ="", main = paste("n = ",n))
par(AA$old.par)

rr <- mult.fig.p(mfrow=c(4,2), main= "Sine functions", cex = 1.5,
               marP = - c(0, 1, 2, 0))
for (n in 1:8)
  plot(x, sin(n * pi * x), type = 'l', col="red", ylab ="")
str(rr)
par(rr$old.par)
## Look at the par setting *AFTER* the above:
str(do.call("par", as.list(names(rr$new.par))))

Run the code above in your browser using DataLab