Debian Codegraph @

man/mult.fig.Rd

raw
1 \name{mult.fig}
2 \alias{mult.fig}
3 \title{Plot Setup for MULTiple FIGures, incl. Main Title}
4 \description{
5 Easy Setup for plotting multiple figures (in a rectangular layout) on
6 one page. It allows to specify a main title and uses \emph{smart}
7 defaults for several \code{\link{par}} calls.
8 }
9 \usage{
10 mult.fig(nr.plots, mfrow, mfcol, marP = rep(0, 4),
11 mgp = c(if(par("las") != 0) 2. else 1.5, 0.6, 0),
12 mar = marP + 0.1 + c(4,4,2,1), oma = c(0,0, tit.wid, 0),
13 main = NULL,
14 tit.wid = if (is.null(main)) 0 else 1 + 1.5*cex.main,
15 cex.main = par("cex.main"), line.main = cex.main - 1/2,
16 col.main = par("col.main"), font.main = par("font.main"), \dots)
17 }
18 \arguments{
19 \item{nr.plots}{integer; the number of plot figures you'll want to draw.}
20 \item{mfrow, mfcol}{\emph{instead} of \code{nr.plots}: integer(2) vectors
21 giving the rectangular figure layout for \code{\link{par}(mfrow = *)},
22 or \code{\link{par}(mfcol=*)}, respectively. The default is to use
23 \code{mfrow = \link{n2mfrow}(nr.plots)}.}
24 \item{marP}{numeric(4) vector of figure margins to \emph{add}
25 (\dQuote{\bold{P}lus}) to default \code{mar}, see below.}
26 \item{mgp}{argument for \code{\link{par}(mpg= .)} with a smaller
27 default than usual.}
28 \item{mar}{argument for \code{\link{par}(mar= .)} with a smaller
29 default than usual, using the \code{marP} argument, see above.}
30 \item{oma}{argument for \code{\link{par}(oma= .)}, by default for
31 adding space for the \code{main} title if necessary.}
32 \item{main}{character. The main title to be used for the whole graphic.}
33 \item{tit.wid}{numeric specifying the vertical width to be used for the
34 main title; note that this is only used for the default value of
35 \code{oma} (s. above).}
36 \item{cex.main}{numeric; the character size to be used for the main title.}
37 \item{line.main}{numeric; the margin line at which the title is written
38 (via \code{\link{mtext}(main, side=3, outer=TRUE, line = line.main, ....)}).}
39 \item{col.main, font.main}{color and font for main title, passed to
40 \code{\link{mtext}()}, see also \code{\link{par}(*)}.}
41 \item{\dots}{further arguments to \code{\link{mtext}} for the main title.}
42 }
43 \value{
44 A \code{\link{list}} with two components that are lists themselves, a
45 subset of \code{\link{par}()},
46 \item{new.par}{the current \code{par} settings.}
47 \item{old.par}{the \code{par} \emph{before} the call.}
48 }
49 \author{Martin Maechler, UW Seattle, 1990 (for \command{S}).}
50 \seealso{\code{\link{par}}, \code{\link{layout}}.}
51 \examples{
52 opl <- mult.fig(5, main= expression("Sine Functions " * sin(n * pi * x)))
53 x <- seq(0, 1, len = 201)
54 for (n in 1:5)
55 plot(x, sin(n * pi * x), ylab ="", main = paste("n = ",n))
56 par(opl$old.par)
57
58 rr <- mult.fig(mfrow=c(5,1), main= "Cosinus Funktionen", cex = 1.5,
59 marP = - c(0, 1, 2, 0))
60 for (n in 1:5)
61 plot(x, cos(n * pi * x), type = 'l', col="red", ylab ="")
62 str(rr)
63 par(rr$old.par)
64 ## The *restored* par settings:
65 str(do.call("par", as.list(names(rr$new.par))))
66
67 ## Manual setting of `tit.wid` in case subsequent code also manages par():
68 mult.fig(4, tit.wid = 2)$old.par -> opar
69 plot(lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings))
70 par(opar) # reset
71 }
72 \keyword{hplot}