next up previous contents
Next: Other Software Up: Splus/R Previous: Object Arithmetic   Contents

Graphics

The graphical capabilities of R and S-plus are one of the most attractive features of the software. Any plot that is made (histogram, x-y plot, etc...) needs to be created on a graphics device. To display the graphic on your screen, open the motif or X11 graphics device and then create the graph. For example, to display a plot of 10 random standard normals against 10 random standard normals, do the following
> X11()   # Opens the graphics window
> plot(rnorm(10),rnorm(10))
in either R or S-plus. Similarly, we could use motif() instead of X11(). To close the graphics device, type dev.off() at the prompt and the device will exit.

In addition, one can create a postscript file (or encapsulated postscript) for inclusion in a paper or presentation by opening the postscript graphics device. To save a histogram of 1000 random normals .eps file, issue the commands

> postscript("normals.eps")  # in S-plus
> hist(rnorm(1000))
> dev.off()
and the file normals.eps is created in your current working directory. Note that the file is not created until you turn the postscript device off using the dev.off() command. In R, you need to specify the paper size as ``letter'' in the postscript command above.
> postscript("normals.eps", paper=''letter'')


next up previous contents
Next: Other Software Up: Splus/R Previous: Object Arithmetic   Contents
Computer Support Group 2002-10-07