The R Project SVN R

Rev

Rev 61168 | Rev 66444 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/grDevices/man/dev.Rd
2
% Part of the R package, http://www.R-project.org
59039 ripley 3
% Copyright 1995-2009 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())
45682 ripley 26
dev.new(\dots)
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.}
27442 ripley 33
}
40618 ripley 34
\details{
35
  Only one device is the \sQuote{active} device: this is the device in
36
  which all graphics operations occur.  There is a \code{"null device"}
37
  which is always open but is really a placeholder: any attempt to use
38
  it will open a new device specified by
39
  \code{\link{getOption}("device")}).
27442 ripley 40
 
41
  Devices are associated with a name (e.g., \code{"X11"} or
40618 ripley 42
  \code{"postscript"}) and a number in the range 1 to 63; the
43
  \code{"null device"} is always device 1.  Once a device has been
44
  opened the null device is not considered as a possible active device.
45
  There is a list of open devices, and this is considered as a circular
46
  list not including the null device.  \code{dev.next} and
47
  \code{dev.prev} select the next open device in the appropriate
48
  direction, unless no device is open.
61433 ripley 49
 
40618 ripley 50
  \code{dev.off} shuts down the specified (by default the current)
51
  device.  If the current device is shut down and any other devices are
52
  open, the next open device is made current.  It is an error to
48750 ripley 53
  attempt to shut down device 1.  \code{graphics.off()} shuts down all
54
  open graphics devices.  Normal termination of a session runs the
55
  internal equivalent of \code{graphics.off()}.
27442 ripley 56
 
40618 ripley 57
  \code{dev.set} makes the specified device the active device.  If there
58
  is no device with that number, it is equivalent to \code{dev.next}.
59
  If \code{which = 1} it opens a new device and selects that.
43727 ripley 60
 
61
  \code{dev.new} opens a new device.  Normally \R will open a new device
62
  automatically when needed, but this enables you to open further
63
  devices in a platform-independent way.  (For which device is used see
64
  \code{\link{getOption}("device")}.)  Note that care is needed with
65
  file-based devices such as \code{\link{pdf}} and
66
  \code{\link{postscript}} and in that case file names such as
67
  \file{Rplots.pdf}, \file{Rplots1.pdf}, \dots, \file{Rplots999.pdf} are
45682 ripley 68
  tried in turn.  Only named arguments are passed to the device, and
69
  then only if they match the argument list of the device.  Even so,
60510 murdoch 70
  care is needed with the interpretation of e.g. \code{width}, and for
61153 ripley 71
  the standard bitmap devices \code{units = "in", res = 72} is forced if
45682 ripley 72
  neither is supplied but both \code{width} and \code{height} are.
27442 ripley 73
}
74
\value{
43727 ripley 75
  \code{dev.cur} returns a length-one named integer vector giving the
76
  number and name of the active device, or 1, the null device, if none
77
  is active.
27442 ripley 78
 
79
  \code{dev.list} returns the numbers of all open devices, except device
43727 ripley 80
  1, the null device.  This is a numeric vector with a
81
  \code{\link{names}} attribute giving the device names, or \code{NULL} is
82
  there is no open device.
27442 ripley 83
 
84
  \code{dev.next} and \code{dev.prev} return the number and name of the
40618 ripley 85
  next / previous device in the list of devices.  This will be the null
86
  device if and only if there are no open devices.
27442 ripley 87
 
43727 ripley 88
  \code{dev.off} returns the number and name of the new active device
27442 ripley 89
  (after the specified device has been shut down).
90
 
43727 ripley 91
  \code{dev.set} returns the number and name of the new active device.
92
 
93
  \code{dev.new} returns the return value of the device opened, usually
94
  invisible \code{NULL}.
27442 ripley 95
}
96
\seealso{
30915 ripley 97
  \code{\link{Devices}}, such as \code{\link{postscript}}, etc.
98
 
27442 ripley 99
  \code{\link{layout}} and its links for setting up plotting regions
100
  on the current device.
101
}
102
\examples{
103
\dontrun{## Unix-specific example
104
x11()
105
plot(1:10)
106
x11()
107
plot(rnorm(10))
108
dev.set(dev.prev())
61168 ripley 109
abline(0, 1) # through the 1:10 points
27442 ripley 110
dev.set(dev.next())
61168 ripley 111
abline(h = 0, col = "gray") # for the residual plot
27442 ripley 112
dev.set(dev.prev())
61168 ripley 113
dev.off(); dev.off() #- close the two X devices
27442 ripley 114
}
115
}
116
\keyword{device}
117
\keyword{iplot}