Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mult.fig

Plot Setup for MULTiple FIGures, incl. Main Title


Description

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

Usage

mult.fig(nr.plots, mfrow, mfcol, marP = rep(0, 4),
         mgp = c(if(par("las") != 0) 2. else 1.5, 0.6, 0),
         mar = marP + 0.1 + c(4,4,2,1), oma = c(0,0, tit.wid, 0),
         main = NULL,
         tit.wid = if (is.null(main)) 0 else 1 + 1.5*cex.main,
         cex.main = par("cex.main"), line.main = cex.main - 1/2,
         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, mfcol

instead of nr.plots: integer(2) vectors giving the rectangular figure layout for par(mfrow = *), or par(mfcol=*), respectively. The default is to use mfrow = n2mfrow(nr.plots).

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.

oma

argument for par(oma= .), by default for adding space for the main title if necessary.

main

character. The main title to be used for the whole graphic.

tit.wid

numeric specifying the vertical width to be used for the main title; note that this is only used for the default value of oma (s. above).

cex.main

numeric; the character size to be used for the main title.

line.main

numeric; the margin line at which the title is written (via mtext(main, side=3, outer=TRUE, line = line.main, ....)).

col.main, font.main

color and font for main title, passed to mtext(), see also par(*).

...

further arguments to mtext for the main title.

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.

Author(s)

Martin Maechler, UW Seattle, 1990 (for S).

See Also

Examples

opl <- mult.fig(5, main= expression("Sine Functions " * sin(n * pi * x)))
x <- seq(0, 1, len = 201)
for (n in 1:5)
  plot(x, sin(n * pi * x), ylab ="", main = paste("n = ",n))
par(opl$old.par)

rr <- mult.fig(mfrow=c(5,1), main= "Cosinus Funktionen", cex = 1.5,
               marP = - c(0, 1, 2, 0))
for (n in 1:5)
  plot(x, cos(n * pi * x), type = 'l', col="red", ylab ="")
str(rr)
par(rr$old.par)
## The *restored* par settings:
str(do.call("par", as.list(names(rr$new.par))))

sfsmisc

Utilities from 'Seminar fuer Statistik' ETH Zurich

v1.1-11
GPL (>= 2)
Authors
Martin Maechler [aut, cre] (<https://orcid.org/0000-0002-8685-9910>), Werner Stahel [ctb] (Functions: compresid2way(), f.robftest(), last(), p.scales(), p.dnorm()), Andreas Ruckstuhl [ctb] (Functions: p.arrows(), p.profileTraces(), p.res.2x()), Christian Keller [ctb] (Functions: histBxp(), p.tachoPlot()), Kjetil Halvorsen [ctb] (Functions: KSd(), ecdf.ksCI()), Alain Hauser [ctb] (Functions: cairoSwd(), is.whole(), toLatex.numeric()*), Christoph Buser [ctb] (to function Duplicated()), Lorenz Gygax [ctb] (to function p.res.2fact()), Bill Venables [ctb] (Functions: empty.dimnames(), primes()), Tony Plate [ctb] (to inv.seq()), Isabelle Fl<fc>ckiger [ctb], Marcel Wolbers [ctb], Markus Keller [ctb], Sandrine Dudoit [ctb], Jane Fridlyand [ctb], Greg Snow [ctb] (to loessDemo()), Henrik Aa. Nielsen [ctb] (to loessDemo()), Vincent Carey [ctb], Ben Bolker [ctb], Philippe Grosjean [ctb], Fr<e9>d<e9>ric Ibanez [ctb], Caterina Savi [ctb], Charles Geyer [ctb], Jens Oehlschl<e4>gel [ctb]
Initial release
2021-04-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.