The <tt>plot()</tt> function



next up previous contents
Next: Displaying multivariate data Up: High-level plotting commands Previous: High-level plotting commands

The plot() function

One of the most frequently used plotting functions in S is the plot() function. This is a generic function: the type of plot produced is dependent on the type or class of the first argument.


plot(x,y)
plot(xy)

If x and y are vectors, plot(x,y) produces a scatterplot of x against y. The same effect can be produced by supplying one argument (second form) as either a list containing two elements x and y or a two-column matrix.


plot(x)

Produces a time series plot if x is a numeric vector or time series object, or an Argand diagram if x is a complex vector.


plot(f)
plot(f,y)

f is a factor object, y is a numeric vector. The first form generates a bar plot of f; the second form produces boxplots of y for each level of f.


plot(df)
plot(~ expr)
plot(y ~ expr)

df is a data frame, y is any object, expr is a list of object names separated by `+' (e.g. a + b + c). The first two forms produce distributional plots of the variables in a data frame (first form) or of a number of named objects (second form). The third form plots y against every object named in expr.




Erik Moledor
Tue Jan 31 21:02:18 EST 1995