Graphics Device to Produce Adobe Portable Document Format

DESCRIPTION:

Creates a PDF file that Adobe Acrobat can render.

USAGE:

pdf.graph(file, horizontal = F, width = 0, height = 0, 
          pointsize = 14, font = 1, color = T, 
          colorspec = if(color) pdf.colors else pdf.grays, 
          colormap = colorspec$colormap, 
          text.colors = colorspec$text.colors, 
          polygon.colors = colorspec$polygon.colors, 
          line.colors = colorspec$line.colors, 
          image.colors = colorspec$image.colors, 
          background.color = colorspec$background.color,
          region = c(0, 0, paper), 
          paper = pdf.page, 
          object, command) 

REQUIRED ARGUMENTS:

file
name of PDF file to produce. See also the object and command arguments.

OPTIONAL ARGUMENTS:

horizontal
if TRUE make picture in landscape orientation, otherwise in portrait.
width
width of plotting region in inches.
height
height of plotting region in inches. To create a figure that takes less than a full page when inserted into other programs, use the paper argument instead of (or in addition to) width and height.
pointsize
size in 1/72s of inch of text when par("cex") is 1.
font
number of default font. Fonts are listed below, 13 is Symbol (contains Greek letters and math symbols) and 35 is ZapfDingbats (contains plotting symbols) and the rest are ordinary text fonts.
color
a logical value. If color is TRUE use colors, if FALSE use grayscale.
colorspec
a list containing containing color information. This argument is ignored unless either use.device.palette(TRUE) or use.legacy.graphics(TRUE) has been called. S-PLUS uses a global color palette and global image color palette.

The list contains a colormap and 4 vectors of indices into that colormap, one vector each for use when drawing lines, text, polygons, and images. The components must be named colormap, line.colors, text.colors, polygon.colors , and image.colors. You may give those components as individual arguments to pdf.graph, if you do they override the corresponding component of colorspec. See below for their detailed descriptions. See the datasets pdf.grays and pdf.colors for examples.

colormap
a numerical vector or matrix. This argument is ignored unless either use.device.palette(TRUE) or use.legacy.graphics(TRUE) has been called.

For grayscale, a vector of numbers between 0 (black) and 1 (white). For color, a 3 column by ncolor row matrix of numbers between 0 and 1. Each row represents a color and its entries give the intensity of its red, green, and blue components. (Instead of this matrix you may also use a ncolor long list of 3 long vectors.)

text.colors
Indices into the colormap giving the colors to use for text. This argument is ignored unless either use.device.palette(TRUE) or use.legacy.graphics(TRUE) has been called.

The color in colormap[text.colors[par("col")]] (or corresponding row of colormap if it is a matrix) will be used when drawing text. Typically, text.colors, line.colors, and polygon.colors will point to contrasting colors.

polygon.colors
indices into colormap for filled polygon colors. This argument is ignored unless either use.device.palette(TRUE) or use.legacy.graphics(TRUE) has been called.
line.colors
indices into colormap for line colors. This argument is ignored unless either use.device.palette(TRUE) or use.legacy.graphics(TRUE) has been called.
image.colors
indices into colormap for image colors. Typically, image.colors will point to a smoothly changing sequence of colors. This argument is ignored unless either use.device.palette(TRUE) or use.legacy.graphics(TRUE) has been called. S-PLUS uses a global image color palette.
background.color
index into colormap for background color. This argument is ignored unless either use.device.palette(TRUE) or use.legacy.graphics(TRUE) has been called. Set the background color by calling par to set the bg graphics parameter.
region
numeric vector of length 4 giving the coordinates of the lower left and upper right corners of the imageable region in inches. It defaults to c(0,0,paper[1],paper[2]), after paper has been converted to inches.
paper
numeric vector of length 2 giving the dimensions of the paper in inches. It can also be given as a string such as "letter", "legal", "A", "B", or "C". The order of the dimensions is not relevant: the horizontal argument determines which is the width; if horizontal=TRUE then the horizontal dimension is larger. The default, given by the dataset pdf.paper, is "letter".
object
A character string containing the name of the Splus character vector into which to place the PDF output. The object will be placed on frame 1 when dev.off() is called -- use get(object, frame=1) in the same top level expression as dev.off() to retrieve it. This is useful for client-server applications which know only how to send Splus objects to the client. The strings in the vector should be pasted together with no separators between them to make a valid PDF instruction sequence. The newlines in the strings should not be changed to carriage return-newline combinations as that would change the cross references in the file.
command
A character string containing an operating system command into which to send the PDF output.

SIDE EFFECTS:

Initializes device driver for creating graphics in the Portable Document Format page description language.

DETAILS:

You cannot view the output file until you call dev.off to close the device driver. You can use this device with Trellis Graphics by starting the device with trellis.device(pdf.graph, file="my.pdf").

The fonts available are

( 1)  Helvetica 
( 2)  Courier 
( 3)  Times-Roman 
( 4)  Helvetica-Oblique 
( 5)  Helvetica-Bold 
( 6)  Helvetica-BoldOblique 
( 7)  Courier-Oblique 
( 8)  Courier-Bold 
( 9)  Courier-BoldOblique 
(10)  Times-Italic 
(11)  Times-Bold 
(12)  Times-BoldItalic 
(13)  Symbol 
(14)  AvantGarde-Book 
(15)  AvantGarde-BookOblique 
(16)  AvantGarde-Demi 
(17)  AvantGarde-DemiOblique 
(18)  Bookman-Demi 
(19)  Bookman-DemiItalic 
(20)  Bookman-Light 
(21)  Bookman-LightItalic 
(22)  Helvetica-Narrow 
(23)  Helvetica-Narrow-Bold 
(24)  Helvetica-Narrow-BoldOblique 
(25)  Helvetica-Narrow-Oblique 
(26)  NewCenturySchlbk-Roman 
(27)  NewCenturySchlbk-Bold 
(28)  NewCenturySchlbk-Italic 
(29)  NewCenturySchlbk-BoldItalic 
(30)  Palatino-Roman 
(31)  Palatino-Bold 
(32)  Palatino-Italic 
(33)  Palatino-BoldItalic 
(34)  ZapfChancery-MediumItalic 
(35)  ZapfDingbats 


The marks made with pch=0:18 are made with characters from the Symbol and ZapfDingbats fonts. They don't look exactly like the marks described in the points help file, but resemble them when possible.

By default, S-PLUS uses a global color palette and global image color palette to map color indices to specific colors. Color arguments can have integer values that map into the color palette, or they can be specified by RGB (or RGBA) values or color names. An RGBA value is a hexadecimal representation of color where the red, green, blue, and alpha channel, or transparency, values are specified. The pdf.graph device supports color transparency. In order to use device specific color schemes, make one of these calls before calling postscript:

    use.device.palette(TRUE)
    use.legacy.graphics(TRUE)

For more information on color specification, see the chapter "Graphics Enhancements" in the Guide to Graphics.

If either use.device.palette(TRUE) or use.legacy.graphics(TRUE) has been called, and if col is a fraction between 0 and 1, pdf.graph() will render that as a blend of the background color ( col=0) and the first line color. Not all graphics devices do this.

REFERENCES:

Adobe Systems, Inc. (1993). Portable Document Format Reference Manual. Addison-Wesley, Reading, Massachusetts.

Adobe website: http://www.adobe.com

SEE ALSO:

See the chapter "S-PLUS Graphic Device Support" in the Guide to Graphics. , , . .

EXAMPLES:

pdf.graph(file="test.pdf") 
par(mfrow=c(2, 1)) 
pie(rep(1, 20)) 
plot(state.x77[,"Frost"], state.x77[,"Murder"], type="n") 
reg <- factor(state.region) 
for(i in seq(along=levels(reg))) { 
        w <- reg == levels(reg)[i] 
        points(state.x77[w,"Frost"], state.x77[w,"Murder"], pch=i, col=i) 
} 
image(voice.five, ylim=c(0, 80)) 
image.legend(voice.five$z, x=range(voice.five$x), y=c(70,80), 
        cex=.5, mgp=c(3,.25,0)) 
tsplot(hstart) 
dev.off() 
# now use Adobe Acrobat Reader, perhaps as a web browser plug-in, 
# to view "test.pdf".  On Unix with Adobe's acroread you can 
# use the following to send it to the viewer: 
unix(paste("acroread -name acroread -useFrontEndProgram", 
        "test.pdf", "&"), out=F)