Graphical Parameters

The following is a list of arguments available to control the appearance of graphs. This list is not meant to be studied, but rather to serve as a reference throughout the section Graphical Methods II.

The following arguments can be specified within any graphical function to specify titles, where string is the title inserted in quotes, or a character vector containing the title:

main title, above plot, in enlarged characters
sub-title for bottom of plot
main="# of chin ups \n Females"
for titles and sub-titles to run over more than one line, use \n in the character string to start a new line
The following parameters may only be used in high-level graphical functions (those that set up coordinate systems, e.g., plot, qqplot).

xlab="string", ylab="string"
labels for the x an y axes
logical flag specifying axes=F forces Splus to omit drawing the axes
xlim=, ylim=
vectors giving the min and max values for the x and y axes
Splus may extend the axes further to produce pretty tick labels
specifies the axes to be logarithmic (ie.: log="xy")
type of plot:
The function par() can be used to set graphical parameters which stay in effect throughout all plotting until they are reset in another call to par or by invoking a new graphic device.

> par(mfrow=c(2,3))
                       * it is possible to specify the number and
                         arrangement of graphs on a page using the
                         mfrow= option
                       * mfrow=c(2,3) allows 6 plots to appear on
                         a page (2 rows of 6 plots each)
                       * because the mfrow argument was used within
                         the par function, the set up will stay in effect 
                         for all subsequent graphs

> par(mfrow=c(1,1))    
                       * restores the normal one-graph-per-page form
                       * this could also be done by invoking a new
                         graphic device
                         > X11()
> par(mfcol=c(3,2))    
                       * the page is set up as above except that the
                         graphs are printed columnwise, mfrow prints
                         graphs row by row
The following arguments can be specified either by the par() function or within a graphics function (for temporary parameter settings which stay in effect only for the call to the function and are then reset to their previous values).

plotting character, the default is pch="*"
it is possible to specify either a character, using quotes, or a numeric value, causing Splus to use one of a set of predefined values:
   Basic symbols            Superimposed symbols        Filled in symbols

   0  square                    7  0 and 4                15  square
   1  octagon                   8  3 and 4                16  octagon
   2  triangle                  9  3 and 5                17  triangle
   3  cross                    10  1 and 3                18  diamond
   4  X                        11  2 and 6
   5  diamond                  12  0 and 3
   6  inverted triangle        13  1 and 4
                               14  0 and 2
character expansion, ie.: cex=0.5 gives half the standard character size
line type: a value of 1 gives solid lines, values of 2,3... will select a non-solid line type
line width: the default value is 1. Increasing values produce thicker lines
numeric color specification (default is 1)
string justification:
a vector specifying the margins on each of the four sides of a multiple figure region:
c(bottom, left, top, right)
where the values specified are the number of lines of text
logical value
ask=T means graphical device will prompt before going to the next page/screen of output (prevents plots from being erased before they are studied)
controls number of tick intervals and length of labels
type of axis labels:
0 parallel to axis
1 horizontal
2 perpendicular to axis
For a list of all the available graphical parameters, type help(par)

Other Useful FUnctions

The arguments main= and sub= cannot be used from within these functions with the exception of title()

points(x,y,pch= )
the function points() allows you to add variables to the current plot
lines(x,y,lty= )
the function lines() allows you to add lines to the current plot
adds a line to a plot
arguments can be specified as:
legend(x,y,legend= )
puts a box at the specified x,y coordinates with examples (if possible) of the lines/points/shading used in the graph identified by user-defined text
identify(x,y,labels= )
similar to legend(), identify() prints text (labels) at the specified points
locator(n= ,type= )
returns the coordinates specified interactively on a plot
default is n=500, type="n"
by changing type, points and/or lines may be added to the plot
the locator() function can be used within the function legend() or identify() instead of specifying the x and y coordinates: legend(locator(1),legend)
the point is identified by placing the cursor over the point and pressing the left mouse button
to exit locator without identifying all "n" points, press the middle mouse button
title(main= , sub= , xlab= , ylab= )
adds titles and/or axis labels to the current plot
will overwrite any existing titles and/or axis labels
adds a line segment with endpoints (x1,y1) and (x2,y2) to the current plot
adds an arrow to the current plot
for a description of optional arguments, type help(segments)
adds text to the current plot
the coordinates can be given by two arguments (x and y) or by a single argument x which is a univariate time series, a complex vector, a matrix with 2 columns, or a list containing components named x and y
mtext("string",side= )
adds text in the margins of the current plot
side specifies the side on which the text is to be placed
  1. bottom
  2. left (default)
  3. top
  4. right
other options are available for this function, use help(mtext)
adds an axis to the current plot
surrounds the current plot with a box

Further Reading

Richard A. Becker, John M. Chambers, Allan R. Wilks, The New S Language. A Programming Environmnent for Data Analysis and Graphics, Wadsworth & Brooks/Cole Advanced Books & Software, Pacific Grove, California, 1988, Chapter 10.