| 42333 |
ripley |
1 |
% File src/library/grDevices/man/dev.Rd
|
| 68948 |
ripley |
2 |
% Part of the R package, https://www.R-project.org
|
| 65675 |
ripley |
3 |
% Copyright 1995-2014 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 49488 |
ripley |
6 |
\name{dev}
|
| 43728 |
ripley |
7 |
\alias{dev.cur}
|
|
|
8 |
\alias{dev.list}
|
|
|
9 |
\alias{dev.next}
|
|
|
10 |
\alias{dev.prev}
|
|
|
11 |
\alias{dev.off}
|
|
|
12 |
\alias{dev.set}
|
|
|
13 |
\alias{dev.new}
|
|
|
14 |
\alias{graphics.off}
|
| 27442 |
ripley |
15 |
\title{Control Multiple Devices}
|
| 43728 |
ripley |
16 |
\description{
|
|
|
17 |
These functions provide control over multiple graphics devices.
|
|
|
18 |
}
|
| 27442 |
ripley |
19 |
\usage{
|
|
|
20 |
dev.cur()
|
|
|
21 |
dev.list()
|
|
|
22 |
dev.next(which = dev.cur())
|
|
|
23 |
dev.prev(which = dev.cur())
|
|
|
24 |
dev.off(which = dev.cur())
|
|
|
25 |
dev.set(which = dev.next())
|
| 65675 |
ripley |
26 |
dev.new(\dots, noRStudioGD = FALSE)
|
| 27442 |
ripley |
27 |
graphics.off()
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
\arguments{
|
| 43727 |
ripley |
31 |
\item{which}{An integer specifying a device number.}
|
| 45682 |
ripley |
32 |
\item{\dots}{arguments to be passed to the device selected.}
|
| 65675 |
ripley |
33 |
\item{noRStudioGD}{Do not use the RStudio graphics device even if
|
|
|
34 |
specified as the default device: it does not accept arguments such
|
|
|
35 |
as \code{width} and \code{height}.}
|
| 27442 |
ripley |
36 |
}
|
| 40618 |
ripley |
37 |
\details{
|
|
|
38 |
Only one device is the \sQuote{active} device: this is the device in
|
|
|
39 |
which all graphics operations occur. There is a \code{"null device"}
|
|
|
40 |
which is always open but is really a placeholder: any attempt to use
|
|
|
41 |
it will open a new device specified by
|
| 74363 |
maechler |
42 |
\code{\link{getOption}("device")}.
|
| 27442 |
ripley |
43 |
|
|
|
44 |
Devices are associated with a name (e.g., \code{"X11"} or
|
| 40618 |
ripley |
45 |
\code{"postscript"}) and a number in the range 1 to 63; the
|
|
|
46 |
\code{"null device"} is always device 1. Once a device has been
|
|
|
47 |
opened the null device is not considered as a possible active device.
|
|
|
48 |
There is a list of open devices, and this is considered as a circular
|
|
|
49 |
list not including the null device. \code{dev.next} and
|
|
|
50 |
\code{dev.prev} select the next open device in the appropriate
|
|
|
51 |
direction, unless no device is open.
|
| 61433 |
ripley |
52 |
|
| 40618 |
ripley |
53 |
\code{dev.off} shuts down the specified (by default the current)
|
|
|
54 |
device. If the current device is shut down and any other devices are
|
|
|
55 |
open, the next open device is made current. It is an error to
|
| 48750 |
ripley |
56 |
attempt to shut down device 1. \code{graphics.off()} shuts down all
|
|
|
57 |
open graphics devices. Normal termination of a session runs the
|
|
|
58 |
internal equivalent of \code{graphics.off()}.
|
| 27442 |
ripley |
59 |
|
| 40618 |
ripley |
60 |
\code{dev.set} makes the specified device the active device. If there
|
|
|
61 |
is no device with that number, it is equivalent to \code{dev.next}.
|
|
|
62 |
If \code{which = 1} it opens a new device and selects that.
|
| 43727 |
ripley |
63 |
|
|
|
64 |
\code{dev.new} opens a new device. Normally \R will open a new device
|
|
|
65 |
automatically when needed, but this enables you to open further
|
|
|
66 |
devices in a platform-independent way. (For which device is used see
|
|
|
67 |
\code{\link{getOption}("device")}.) Note that care is needed with
|
|
|
68 |
file-based devices such as \code{\link{pdf}} and
|
|
|
69 |
\code{\link{postscript}} and in that case file names such as
|
|
|
70 |
\file{Rplots.pdf}, \file{Rplots1.pdf}, \dots, \file{Rplots999.pdf} are
|
| 45682 |
ripley |
71 |
tried in turn. Only named arguments are passed to the device, and
|
|
|
72 |
then only if they match the argument list of the device. Even so,
|
| 66444 |
hornik |
73 |
care is needed with the interpretation of e.g.\sspace{}\code{width}, and for
|
| 61153 |
ripley |
74 |
the standard bitmap devices \code{units = "in", res = 72} is forced if
|
| 45682 |
ripley |
75 |
neither is supplied but both \code{width} and \code{height} are.
|
| 27442 |
ripley |
76 |
}
|
|
|
77 |
\value{
|
| 43727 |
ripley |
78 |
\code{dev.cur} returns a length-one named integer vector giving the
|
|
|
79 |
number and name of the active device, or 1, the null device, if none
|
|
|
80 |
is active.
|
| 27442 |
ripley |
81 |
|
|
|
82 |
\code{dev.list} returns the numbers of all open devices, except device
|
| 43727 |
ripley |
83 |
1, the null device. This is a numeric vector with a
|
|
|
84 |
\code{\link{names}} attribute giving the device names, or \code{NULL} is
|
|
|
85 |
there is no open device.
|
| 27442 |
ripley |
86 |
|
|
|
87 |
\code{dev.next} and \code{dev.prev} return the number and name of the
|
| 40618 |
ripley |
88 |
next / previous device in the list of devices. This will be the null
|
|
|
89 |
device if and only if there are no open devices.
|
| 27442 |
ripley |
90 |
|
| 43727 |
ripley |
91 |
\code{dev.off} returns the number and name of the new active device
|
| 27442 |
ripley |
92 |
(after the specified device has been shut down).
|
|
|
93 |
|
| 43727 |
ripley |
94 |
\code{dev.set} returns the number and name of the new active device.
|
|
|
95 |
|
|
|
96 |
\code{dev.new} returns the return value of the device opened, usually
|
|
|
97 |
invisible \code{NULL}.
|
| 27442 |
ripley |
98 |
}
|
|
|
99 |
\seealso{
|
| 30915 |
ripley |
100 |
\code{\link{Devices}}, such as \code{\link{postscript}}, etc.
|
|
|
101 |
|
| 27442 |
ripley |
102 |
\code{\link{layout}} and its links for setting up plotting regions
|
|
|
103 |
on the current device.
|
|
|
104 |
}
|
|
|
105 |
\examples{
|
|
|
106 |
\dontrun{## Unix-specific example
|
|
|
107 |
x11()
|
|
|
108 |
plot(1:10)
|
|
|
109 |
x11()
|
|
|
110 |
plot(rnorm(10))
|
|
|
111 |
dev.set(dev.prev())
|
| 61168 |
ripley |
112 |
abline(0, 1) # through the 1:10 points
|
| 27442 |
ripley |
113 |
dev.set(dev.next())
|
| 61168 |
ripley |
114 |
abline(h = 0, col = "gray") # for the residual plot
|
| 27442 |
ripley |
115 |
dev.set(dev.prev())
|
| 61168 |
ripley |
116 |
dev.off(); dev.off() #- close the two X devices
|
| 27442 |
ripley |
117 |
}
|
|
|
118 |
}
|
|
|
119 |
\keyword{device}
|
|
|
120 |
\keyword{iplot}
|