\documentstyle[fullpage,psfig]{article} % psfig: enable postscript figure handling % fullpage: use full page format \begin{document} % this is a comment \begin{center} \bf Catalyst Interaction Plot with S \end{center} \noindent Here is a way to get nice interaction plots with S. The {\tt catalyst} example from {\em Statistical Models in S} by Chambers and Hastie (1992) is used to illustrate concepts. The file that created this document is called {\tt catalyst.tex}\ . \\\\ {\bf 1. Turn on a graphics driver.} On an X-window (e.g.\ NCD terminal), use the graphics device {\tt x11()} (for S) or {\tt motif()} (for Splus), or on a dumb keyboard terminal use {\tt printer()}. Mac and PC platforms having a ``tektronics'' emulator might try the graphics device {\tt tek4014()}. Note that only one graphics device can be on at a time; calling a second one turns off the first. \\\\ {\bf 2. Play around interactively with plots in S.} Do this until you find what you want. Try my {\tt lsd.plot} as an alternative to {\tt interaction.plot} (but you must first call {\tt library(pda)}). \\\\ {\bf 3. Construct a file of plot commands.} This helps keeps track of plots that work well. Build ideas interactively in S, using a separate editing window or invoking an editor from within S (e.g.\ {\tt !emacs catplot.s}) to update your file. Here is my file {\tt catplot.s}: \begin{verbatim} motif() par(mfcol=c(1,2)) plot(catalyst) attach(catalyst) interaction.plot(Conc, Cat, Yield) detach("catalyst") \end{verbatim} {\bf 4. Turn on the {\tt postscript()} device driver.} This saves the plot in a postscript file. Use the {\tt postscript} command defaults if you want to have a full page plot, or change the {\tt height}, {\tt width} and {\tt pointsize} for smaller plots for reports. Source your plot commands. Then turn off the graphics device with {\tt graphics.off()} (or reinvoke your favorite) to close the postscript file, called {\tt catplot.ps} here. \begin{verbatim} postscript("catplot.ps",height=4,width=6,pointsize=10,horizontal=F) source("catplot.s") dev.off() \end{verbatim} \noindent {\bf 5. Examine the plots.} The figure on the next page was plotted with the following commands: \begin{verbatim} \begin{figure}[htb] \centerline{\psfig{figure=catplot.ps}} \caption{Catalyst Main Effects and Interactions} \end{figure} \end{verbatim} % here are the actual plot commands for LaTeX: \begin{figure}[htb] \centerline{\psfig{figure=catplot.ps}} \caption{Catalyst Main Effects and Interactions} \end{figure} {\bf 6. View the PostScript plot.} There is a {\tt ghostview()} command (as well {\tt lpr()}, {\tt lpq()} and {\tt enscript()}) in the {\tt library(pda)} to make viewing and printing easier: \begin{verbatim} > library(pda) > ghostview("catplot.ps") # if it looks OK and you can print it from within ghostview # or send it to laserprinter with lpr > lpr("catplot.ps") # check the printer queue > lpq() \end{verbatim} Note: {\tt ghostview} takes a moment to display your graphics. The {\tt ghostview()} command in S stays active by default. You can update your postscript file and reopen it. \\\\ {\bf 7. Examine the \LaTeX\ source for this document.} You may want to learn how to embed plots in your reports. See this file ({\tt catalyst.tex}) for an example. Once you have made created {\tt catplot.ps}, and have the file {\tt catalyst.tex}, do the following (from UNIX, not S!): \begin{verbatim} % latex catalyst % dvips catalyst % ghostview catalyst.ps \end{verbatim} The command {\tt dvips} converts {\tt catalyst.dvi} to a PostScript file {\tt catalyst.ps}. (You must specify the {\tt .ps} ending for {\tt ghostview}.) The document viewer {\tt xdvi} can examine {\tt catalyst.dvi} directly: \begin{verbatim} % xdvi catalyst \end{verbatim} {\bf 8. Print the PostScript document.} When you are satisfied with your plot and document, you can send it to the printer if you have not done this from within {\tt ghostview}\,. The UNIX command is either \begin{verbatim} % dvipr catalyst \end{verbatim} or, if you used {\tt dvips} to create a PostScript file, \begin{verbatim} % lpr catalyst.ps \end{verbatim} {\bf WARNING:} Postscript files take space. Delete them if not needed. \\\\ {\bf 9. Translate PostScript to GIF or JPEG.} The {\tt xv} command can be used on an X terminal to translate {\tt catplot.ps} into {\tt catplot.gif} or {\tt catplot.jpeg} which can be embedded in Word documents on Macs or Windows systems. Type \begin{verbatim} % xv catplot.ps \end{verbatim} Once the image is up, click the right mouse button for the menu. \end{document}