plot.default            package:graphics            R Documentation

_T_h_e _D_e_f_a_u_l_t _S_c_a_t_t_e_r_p_l_o_t _F_u_n_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Draw a scatter plot with "decorations" such as axes and titles in
     the active graphics window.

_U_s_a_g_e:

     ## Default S3 method:
     plot(x, y = NULL, type = "p",  xlim = NULL, ylim = NULL,
          log = "", main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
          ann = par("ann"), axes = TRUE, frame.plot = axes,
          panel.first = NULL, panel.last = NULL, asp = NA, ...)

_A_r_g_u_m_e_n_t_s:

    x, y: the 'x' and 'y' arguments provide the x and y coordinates for
          the plot.  Any reasonable way of defining the coordinates is
          acceptable.  See the function 'xy.coords' for details.

    type: 1-character string giving the type of plot desired.  The
          following values are possible, for details, see 'plot': '"p"'
          for points, '"l"' for lines, '"o"' for overplotted points and
          lines, '"b"', '"c"') for (empty if '"c"') points joined by
          lines, '"s"' and '"S"' for stair steps and '"h"' for
          histogram-like vertical lines.  Finally, '"n"' does not
          produce any points or lines.

    xlim: the x limits (x1,x2) of the plot.  Note that 'x1 > x2' is
          allowed and leads to a "reversed axis".

    ylim: the y limits of the plot.

     log: a character string which contains '"x"' if the x axis is to
          be logarithmic, '"y"' if the y axis is to be logarithmic and
          '"xy"' or '"yx"' if both axes are to be logarithmic.

    main: a main title for the plot, see also 'title'.

     sub: a sub title for the plot.

    xlab: a label for the x axis, defaults to a description of 'x'.

    ylab: a label for the y axis, defaults to a description of 'y'.

     ann: a logical value indicating whether the default annotation
          (title and x and y axis labels) should appear on the plot.

    axes: a logical value indicating whether both axes should be drawn
          on the plot.  Use graphical parameter '"xaxt"' or '"yaxt"' to
          suppress just one of the axes.

frame.plot: a logical indicating whether a box should be drawn around
          the plot.

panel.first: an expression to be evaluated after the plot axes are set
          up but before any plotting takes place.  This can be useful
          for drawing background grids or scatterplot smooths.

panel.last: an expression to be evaluated after plotting has taken
          place.

     asp: the y/x aspect ratio, see 'plot.window'.

     ...: other graphical parameters (see 'par' and section 'Details'
          below).

_D_e_t_a_i_l_s:

     Commonly used graphical parameters are:

     '_c_o_l' The colors for lines and points.  Multiple colors can be
          specified so that each point can be given its own color.  If
          there are fewer colors than points they are recycled in the
          standard fashion.  Lines will all be plotted in the first
          colour specified.

     '_b_g' a vector of background colors for open plot symbols, see
          'points'.  Note: this is *not* the same setting as
          'par("bg")'.

     '_p_c_h' a vector of plotting characters or symbols: see 'points'.

     '_c_e_x' a numerical vector giving the amount by which plotting text
          and symbols should be scaled relative to the default.  This
          works as a multiple of 'par("cex")'. 'NULL' and 'NA' are
          equivalent to '1.0'.

     '_l_t_y' the line type, see 'par'.

     '_c_e_x._m_a_i_n, _c_o_l._l_a_b, _f_o_n_t._s_u_b', _e_t_c settings for main- and
          sub-title and axis annotation, see 'title' and 'par'.

     '_l_w_d' the line width, see 'par'.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

     Cleveland, W. S. (1985) _The Elements of Graphing Data._ Monterey,
     CA: Wadsworth.

     Murrell, P. (2005) _R Graphics_. Chapman & Hall/CRC Press.

_S_e_e _A_l_s_o:

     'plot', 'plot.window', 'xy.coords'.

_E_x_a_m_p_l_e_s:

     Speed <- cars$speed
     Distance <- cars$dist
     plot(Speed, Distance, panel.first = grid(8,8),
          pch = 0, cex = 1.2, col = "blue")
     plot(Speed, Distance,
          panel.first = lines(lowess(Speed, Distance), lty = "dashed"),
          pch = 0, cex = 1.2, col = "blue")

     ## Show the different plot types
     x <- 0:12
     y <- sin(pi/5 * x)
     op <- par(mfrow = c(3,3), mar = .1+ c(2,2,3,1))
     for (tp in c("p","l","b",  "c","o","h",  "s","S","n")) {
        plot(y ~ x, type = tp,
             main = paste("plot(*, type = \"",tp,"\")",sep=""))
        if(tp == "S") {
           lines(x,y, type = "s", col = "red", lty = 2)
           mtext("lines(*, type = \"s\", ...)", col = "red", cex=.8)
        }
     }
     par(op)

     ##--- Log-Log Plot  with  custom axes
     lx <- seq(1,5, length=41)
     yl <- expression(e^{-frac(1,2) * {log[10](x)}^2})
     y <- exp(-.5*lx^2)
     op <- par(mfrow=c(2,1), mar=par("mar")+c(0,1,0,0))
     plot(10^lx, y, log="xy", type="l", col="purple",
          main="Log-Log plot", ylab=yl, xlab="x")
     plot(10^lx, y, log="xy", type="o", pch='.', col="forestgreen",
          main="Log-Log plot with custom axes", ylab=yl, xlab="x",
          axes = FALSE, frame.plot = TRUE)
     axis(1, at = my.at <- 10^(1:5), labels = formatC(my.at, format="fg"))
     at.y <- 10^(-5:-1)
     axis(2, at = at.y, labels = formatC(at.y, format="fg"), col.axis="red")
     par(op)

