Previous: Graphing Commands Up: Graphing Commands Next: Adding Points, Lines, and


Drawing Plots

The most generic plotting command is plot(), which automatically recognizes the type of R object(s) you are trying to plot and selects the best type of plot. The most common graphs returned by plot() are as follows:

  1. If X is a variable of length $ n$, plot(X) returns a scatter plot of $ (x_i, i)$ for $ i = 1, \dots n$. If X is unsorted, this procedure produces a messy graph. Use plot(sort(X)) to arrange the plotted values of $ (x_i, i)$ from smallest to largest.
  2. With two numeric vectors X and Y, both of length $ n$, plot(X, Y) plots a scatter plot of each point $ (x_i, y_i)$ for $ i = 1, \dots n$. Alternatively, if Z is an object with two vectors, plot(Z) also creates a scatter plot.

Optional arguments specific to plot include:

For additional plotting options, refer to help(par).



Gary King 2007-06-01