File: gridOMI.Rd

package info (click to toggle)
r-cran-gridbase 0.4-7-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 340 kB
  • sloc: sh: 16; makefile: 2
file content (107 lines) | stat: -rw-r--r-- 2,766 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
\name{Set Base Plot Regions}
\alias{gridOMI}
\alias{gridFIG}
\alias{gridPLT}
\alias{gridPAR}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{ Set Base Plotting Regions from Grid Viewport }
\description{
  These functions can be used to align base plotting regions
  with the current grid
  viewport.  This can be used to draw base plots within a grid viewport.
}
\usage{
gridOMI()
gridFIG()
gridPLT()
gridPAR()
}
\details{
  For this to be useful, you will have to make liberal use of
  \code{par(new=TRUE)} to prevent base from moving to a new page.

  With care, these can even be used to draw multiple base plots within
  a grid viewport (see the examples below), but in general, base
  plotting functions that draw multiple panels (e.g., \code{coplot})
  should not be
  expected to work.
}
%- maybe also 'usage' for other objects documented here.
\value{
  \code{gridOMI} returns a value that can be used to set the
  \code{par(omi)} parameter.

  \code{gridFIG} returns a value that can be used to set the
  \code{par(fig)} parameter.

  \code{gridPLT} returns a value that can be used to set the
  \code{par(plt)} parameter.

  \code{gridPAR} returns a value that can be used to set
  some graphical parameters (currently, \code{lwd}, \code{lty},
  and \code{col}).
}
\author{ Paul Murrell }

\section{Warning}{ If you resize the device, all bets are off! }
\seealso{ \link{Grid}, \code{\link{viewport}} }
\examples{
library(grid)
opar <- par(no.readonly=TRUE)
# gridFIG
grid.newpage()
pushViewport(viewport(width=0.5, height=0.5))
grid.rect(gp=gpar(col="grey", lty="dashed"))
par(fig=gridFIG())
par(new=TRUE)
plot(1:10)
# multiple plots
# NOTE the use of par(mfg)
# gridOMI
par(opar)
grid.newpage()
pushViewport(viewport(width=0.5, height=0.5))
grid.rect(gp=gpar(col="grey", lty="dashed"))
par(omi=gridOMI())
par(mfrow=c(2, 2), mfg=c(1, 1), mar=c(3, 3, 1, 0))
for (i in 1:4) {
  plot(i)
}
# gridPLT
par(opar)
grid.newpage()
pushViewport(viewport(width=0.5, height=0.5))
grid.rect(gp=gpar(col="grey", lwd=5))
par(plt=gridPLT())
par(new=TRUE)
plot(1:10)
# gridFIG with par(omi) set
par(opar)
grid.newpage()
par(omi=rep(1, 4))
pushViewport(viewport(width=0.5, height=0.5))
grid.rect(gp=gpar(col="grey", lwd=5))
par(fig=gridFIG())
par(new=TRUE)
plot(1:10)
# gridPLT with par(omi) set
par(opar)
grid.newpage()
par(omi=rep(1, 4))
pushViewport(viewport(width=0.5, height=0.5))
grid.rect(gp=gpar(col="grey", lwd=5))
par(plt=gridPLT())
par(new=TRUE)
plot(1:10)
# gridPAR
par(opar)
grid.newpage()
pushViewport(viewport(width=0.5, height=0.5,
  gp=gpar(col="red", lwd=3, lty="dotted")))
grid.rect(gp=gpar(col="grey", lwd=5))
par(fig=gridFIG())
par(gridPAR())
par(new=TRUE)
plot(1:10, type="b")
}
\keyword{ dplot }% at least one, from doc/KEYWORDS