postscript(file = "", width = <<see below>>, height = <<see below>>, append = F, onefile = T, print.it = <<see below>>, ...)
This command will always generate output to a file. If all output is going to one file (i.e. onefile=TRUE) and the file argument has been specified, then output will go to the specified file. Otherwise, a filename will be generated using the ps.options()$tempfile setting. If the output is to be printed using the ps.options()$command string, the filename will be appended to the command string separated by a space. The resulting command will be executed.
This driver follows the Adobe Document Structuring Convention Specifications Version 3. The first line of a PostScript file following the convention is:
%!PS-Adobe-3.0
A subset of this convention is Encapsulated PostScript; the first line of an Encapsulated PostScript file is:
%!PS-Adobe-3.0 EPSF-3.0
Encapsulated PostScript also insists that the file represents only one page. The postscript driver uses the header for Encapsulated PostScript when onefile=FALSE, and the other header when onefile=TRUE. This is a best guess strategy, as there can be more than one page of graphics produced with one call to a graphics function. Some programs that use Encapsulated PostScript may still accept a file with the non-Encapsulated header as long as it is a file for only one page.
This driver supports variable character sizes, general string and character rotations and ten line styles. Line width is specified by the lwd parameter, and is interpreted in units of 1/36 inches, hence the default lwd=1 line is 2 points wide. A line width of 0 gives the thinnest possible line on the device. Fonts that are normally filled (all but the Courier family) may be outlined by specifying the font as a negative number. The pch graphical parameter will select plotting characters from the Standard Encoding vector of PostScript (see the PostScript Language Reference Manual). When plotted these characters are always centered.
Do not allow two different instances of a graphics device write to the same file. The file will become corrupted if this happens. It is possible to generate this problem if both file and onefile=FALSE are specified. See above warnings for the onefile argument.
Some PostScript printers impose a limit on the number of vertices there can be in a polygon. Current models of Apple LaserWriters, for instance, have a limit of about 1500 vertices. The postscript driver will output an outline for most of a polygon, if there are too many vertices. This limit can be controlled via the ps.options(max.vertices=n) command.
Adobe Systems, Inc. (1990). PostScript Language Reference Manual, second edition. Addison-Wesley, Reading, Massachusetts.
# Example 1 postscript() tsplot(hstart, log="y") dev.off() Finished postscript file, executing command "lp ps.out.0004.ps &".# Example 2 - the behavior of onefile postscript("plots.ps") #onefile = T #plots will accumulate in plots.ps (one per page) plot(corn.rain) plot(corn.yield) dev.off() Generated postscript file "plots.ps". # file is not printed automatically, user must # explicitly print it. # file is not encapsulated, i.e., not suitable for # inclusion in other documents
postscript("fig1.eps", onefile=F) plot(corn.rain) plot(corn.yield) Starting to make postscript file. Finished postscript file, executing command "lp fig1.eps &". #first figure has just printed dev.off() Starting to make postscript file. Finished postscript file, executing command "lp fig1.eps &". # both plots have printed, but fig1.eps contains # only the second plot!
postscript("fig1.eps", onefile = F, print.it=F) plot(corn.rain) plot(corn.yield) Starting to make postscript file. Generated postscript file "fig1.eps". dev.off() Starting to make postscript file. Generated postscript file "fig1.eps". #fig1.eps contains only the second plot! no plots have printed!
#in either of the above two cases fig1.eps can be included in #other documents as a figure using an appropriate package for #including postscript files
# Example 3 #use ps.options variables within the postscript command sun.sp <- spectrum(sunspots, spans = c(19, 19, 19), plot = F) postscript(horizontal = T) #ps.options variable creates spec.plot(sun.sp) #landscape plot dev.off()
# Example 4 # the example plot is produced by plot(1:8, axes=F, type="n", ylab="lty", xlab="") for (i in 1:8) abline(h=i, lty=i) axis(2, at=1:8) box()