
To construct graphical plots with S-PLUS it is necessary to open a graphical device. For this course we will be using the graphical device motif. To open the motif window we simply type
> motif()
If we wish to specify the size and position of the window we will use the -geometry option as follows:
> motif("-geometry 600x400-0+0")
A window of size 600x400 will appear in the top right corner. Note that it may be necessary to close colour intense applications such as Netscape in order to open the motif window. These applications can be opened again after the motif window is opened. The motif window can be closed using the graphics.off(). Note that quitting S-PLUS with the q() command will perform a graphics.off operation. The window should not be closed by closing the motif window.
The basic plotting function is the plot function. As an example we will obtain plots for the rockers data set.
> plot(rockers[,"height"], rockers[, "weight"],
+ xlab="Rockers Height", ylab="Rockers Weight",
+ main="3.1 Plot of Height vs Weight")
This figure can be seen in Figure 3.1. Observe that in this plot the missing value is not plotted. We can plot the text instead of the dots by first plotting the data with no points
> plot(rockers[,"height"], rockers[,"weight"],
+ xlab="Rockers Height", ylab="Rockers Weight",
+ main="3.2 Plot of Height vs Weight by Text",
+ type="n")
then using the text function to plot the text.
> text(rockers[,"height"], rockers[,"weight"],
labels=dimnames(rockers)[[1]])
> # Figure 3.2
This figure should be similar to Figure 3.2. To obtain a hardcopy of the plot, issue the command
> postscript()
A name can be assigned to the diagram output using the command
> postscript("file_name")
After the postscript command has been issued, issue the commands for the desired plot. The plot will be stored in your working directory.
