Create Graph File

DESCRIPTION:

Function to save a graph object to a file in any of the cross-platform graph file formats. The object may be a Trellis object, string, or an expression that can be evaluated to create a graph. This function opens the appropriate device, creates the graph, and closes the device.

USAGE:

createGraphFile(obj, fileName=NULL, fileType=NULL, trellisDevice=F, verbose=F, ...)

REQUIRED ARGUMENTS:

obj
a Trellis object, string, or an expression that can be evaluated to create a graph.
fileName
the name for the new graph file.

OPTIONAL ARGUMENTS:

fileType
the type of graph file to create. Options are WMF, PDF, PS, EPS, SPJ, JPG, TIF, PNG, PNM, and BMP. If fileType is missing, the type is determined by the fileName's extension (the characters after the last period).
trellisDevice
logical flag indicating whether to use a Trellis graphics device. If trellisDevice=T, the trellis.device() function is used to invoke the appropriate device, and hence the Trellis colorscheme is used. Otherwise the standard default color scheme is used.
verbose
logical flag indicating whether to print a message with the file name and type.
...
Additional arguments are passed on when opening the graphics device.

VALUE:

Invisibly returns the fileName.

SIDE EFFECTS:

Opens a graphics device, creates a graph file, and closes the device.

DETAILS:

This utility function provides a consistent way to save a graph to a variety of different file types. It invokes the appropriate device for the file type, create the graph, and closes the device. The devices used are wmf.graph for WMF, pdf.graph for PDF, postscript for PS and EPS, and java.graph for SPJ, JPEG, JPG, TIF, PNG, PNM, or BMP. Note that java.graph requires Java-enabled S-PLUS. On Windows, Java can be enabled by loading the winjava library. On UNIX, Java can be enabled by using Splus -j or Splus -g to start S-PLUS. This function is in the menu library.

SEE ALSO:

, , ,

EXAMPLES:

obj <- xyplot(Mileage~Weight | Type, data=fuel.frame)
createGraphFile(obj, fileName="my_xyplot.pdf", fileType="PDF")

createGraphFile("image(voice.five)", fileName="my_image.wmf")

expr <- expression(example.contour())
createGraphFile(expr, "my_contour.jpg", trellis=T, verbose=T)