The R Project SVN R

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
27442 ripley 1
\name{dev2}
2
\alias{dev.copy}
3
\alias{dev.print}
4
\alias{dev.copy2eps}
5
\alias{dev.control}
6
\title{Copy Graphics Between Multiple Devices}
7
\usage{
8
dev.copy(device, \dots, which = dev.next())
9
dev.print(device = postscript, \dots)
10
dev.copy2eps(\dots)
11
dev.control(displaylist = c("inhibit", "enable"))
12
}
13
\arguments{
14
  \item{device}{A device function (e.g., \code{x11},
15
    \code{postscript}, \ldots)}
16
  \item{\dots}{Arguments to the \code{device} function above.
17
    For \code{dev.print}, this includes \code{which} and by default any
18
    \code{\link{postscript}} arguments.}
19
  \item{which}{A device number specifying the device to copy to}
20
  \item{displaylist}{A character string: the only valid values are
21
    \code{"inhibit"} and \code{"enable"}.}
22
}
23
\description{
24
  \code{dev.copy} copies the graphics contents of the current device
25
  to the device specified by \code{which} or to a new device which has
26
  been created by the function specified by \code{device} (it is an
27
  error to specify both \code{which} and \code{device}).  (If recording
28
  is off on the current device, there are no contents to copy: this will
29
  result in no plot or an empty plot.)
30
  The device copied to becomes the current device.
31
 
32
  \code{dev.print} copies the graphics contents of the current device
33
  to a new device which has been created by the function specified by
34
  \code{device} and then shuts the new device.
35
 
36
  \code{dev.copy2eps} is similar to \code{dev.print} but produces an
37
  EPSF output file, in portrait orientation (\code{horizontal = FALSE})
38
 
39
  \code{dev.control} allows the user to control the recording of
40
  graphics operations in a device.  If \code{displaylist} is \code{"inhibit"}
41
  (\code{"enable")} then recording is turned off (on). It is only safe
42
  to change this at the beginning of a plot (just before or just after a
43
  new page).  Initially recording is on for screen devices, and off for
44
  print devices.
45
}
46
\value{
47
  \code{dev.copy} returns the name and number of the device which has
48
  been copied to.
49
 
50
  \code{dev.print} and \code{dev.copy2eps} return the name and number of
51
  the device which has been copied from.
52
}
53
\details{
54
  For \code{dev.copy2eps}, \code{width} and \code{height} are taken
55
  from the current device unless otherwise specified.  If just one of
56
  \code{width} and \code{height} is specified, the other is adjusted
57
  to preserve the aspect ratio of the device being copied.  The default
58
  file name is \code{Rplot.eps}.
59
 
60
#ifdef unix
61
  The default for \code{dev.print} is to produce and print a postscript
62
  copy, if \code{\link{options}("printcmd")} is set suitably.
63
#endif
64
#ifdef windows
65
  The default for \code{dev.print} is to produce and print a postscript
66
  copy.  This will not work unless
67
  \code{\link{options}("printcmd")} is set suitably and you have a
68
  PostScript printer: see \code{\link{postscript}} for how to set this
69
  up.  Windows users may prefer to use \code{dev.print(win.print)}.
70
#endif
71
 
72
 
73
  \code{dev.print} is most useful for producing a postscript print
74
  (its default) when the following applies.  Unless
75
  \code{file} is specified, the plot will be printed.  Unless
76
  \code{width}, \code{height} and \code{pointsize} are specified
77
  the plot dimensions will be taken from the current device, shrunk
78
  if necessary to fit on the paper. (\code{pointsize} is rescaled if the
79
  plot is shrunk.)  If \code{horizontal} is not specified and the plot
80
  can be printed at full size by switching its value this is done
81
  instead of shrinking the plot region.
82
 
83
  If \code{dev.print} is used with a specified device (even
84
  \code{postscript}) it sets the width and height in the same way as
85
  \code{dev.copy2eps}.
86
}
87
\note{
88
  Most devices (including all screen devices) have a display list
89
  which records all of the graphics operations that occur in the device.
90
  \code{dev.copy} copies graphics contents by copying the display list
91
  from one device to another device.  Also, automatic redrawing of
92
  graphics contents following the resizing of a device depends on the
93
  contents of the display list.
94
 
95
  After the command \code{dev.control("inhibit")}, graphics operations
96
  are not recorded in the display list so that \code{dev.copy} and
97
  \code{dev.print} will not copy anything and the contents of a device
98
  will not be redrawn automatically if the device is resized.
99
 
100
  The recording of graphics operations is relatively expensive in
101
  terms of memory so the command \code{dev.control("inhibit")} can be
102
  useful if memory usage is an issue.
103
}
104
\seealso{
105
  \code{\link{dev.cur}} and other \code{dev.xxx} functions
106
}
107
\examples{
108
\dontrun{
109
x11()
110
plot(rnorm(10), main="Plot 1")
111
dev.copy(device=x11)
112
mtext("Copy 1", 3)
113
dev.print(width=6, height=6, horizontal=FALSE) # prints it
114
dev.off(dev.prev())
115
dev.off()
116
}
117
}
118
\keyword{device}