The R Project SVN R

Rev

Rev 68948 | Rev 85953 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 68948 Rev 77447
Line 1... Line 1...
1
% File src/library/grDevices/man/n2mfrow.Rd
1
% File src/library/grDevices/man/n2mfrow.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2007 R Core Team
3
% Copyright 1995-2019 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{n2mfrow}
6
\name{n2mfrow}
7
\alias{n2mfrow}
7
\alias{n2mfrow}
8
\title{Compute Default mfrow From Number of Plots}
8
\title{Compute Default 'mfrow' From Number of Plots}
9
\description{
9
\description{
10
  Easy setup for plotting multiple figures (in a rectangular layout) on
10
  Easy setup for plotting multiple figures (in a rectangular layout) on
11
  one page.  This computes a sensible default for
11
  one page.  This computes a sensible default for
12
  \code{\link{par}(mfrow)}.
12
  \code{\link{par}(mfrow)}.
13
}
13
}
14
\usage{
14
\usage{
15
n2mfrow(nr.plots)
15
n2mfrow(nr.plots, asp = 1)
16
}
16
}
17
\arguments{
17
\arguments{
18
  \item{nr.plots}{integer; the number of plot figures you'll want to draw.}
18
  \item{nr.plots}{integer; the number of plot figures you'll want to draw.}
-
 
19
  \item{asp}{positive number; the target aspect ratio (columns / rows) in
-
 
20
    the output.  Was implicitly hardwired to \code{1}; because of that and
-
 
21
    back compatibility, there is a somewhat discontinuous behavior when
-
 
22
    varying \code{asp} around 1, for \code{nr.plots <= 12}.}
19
}
23
}
20
\value{
24
\value{
21
  A length two integer vector \code{nr, nc} giving the number of rows
25
  A length-two integer vector \code{(nr, nc)} giving the positive number of rows
22
  and columns, fulfilling \code{nr >= nc >= 1} and \code{nr * nc >= nr.plots}.
26
  and columns, fulfilling \code{nr * nc >= nr.plots}, and currently, for
-
 
27
  \code{asp = 1}, \code{nr >= nc >= 1}.
23
}
28
}
-
 
29
\note{
-
 
30
  Conceptually, this is a quadratic integer optimization problem, with
-
 
31
  inequality constraints \eqn{nr >= 1}, \eqn{nc >= 1}, and
-
 
32
  \eqn{nr.plots >= nr*nc} (and possibly \code{nr >= asp*nc}),
-
 
33
  and \emph{two} objective functions which would have to be combined via a
-
 
34
  tuning weight, say \eqn{w}, to, e.g.,
-
 
35
  \eqn{(nr.plots - nr*nc)  + w |nr/nc - asp|}.
-
 
36
 
-
 
37
  The current algorithm is simple and not trying to solve one of these
24
\author{Martin Maechler}
38
  optimization problems.
-
 
39
}
-
 
40
\author{Martin Maechler; suggestion of \code{asp} by Michael Chirico.}
25
\seealso{\code{\link{par}}, \code{\link{layout}}.}
41
\seealso{\code{\link{par}}, \code{\link{layout}}.}
26
\examples{
42
\examples{
27
require(graphics)
43
require(graphics)
28
 
44
 
29
n2mfrow(8) # 3 x 3
45
n2mfrow(8) # 3 x 3
Line 33... Line 49...
33
op <- par(mfrow = n2mfrow(n))
49
op <- par(mfrow = n2mfrow(n))
34
for (j in 1:n)
50
for (j in 1:n)
35
   plot(x, x^j, main = substitute(x^ exp, list(exp = j)), type = "l",
51
   plot(x, x^j, main = substitute(x^ exp, list(exp = j)), type = "l",
36
   col = "blue")
52
   col = "blue")
37
 
53
 
38
sapply(1:10, n2mfrow)
54
sapply(1:14, n2mfrow)
-
 
55
sapply(1:14, n2mfrow, asp=16/9)
39
}
56
}
40
\keyword{dplot}
57
\keyword{dplot}
41
\keyword{utilities}
58
\keyword{utilities}