Scatter Plot with Smooth Curve Fitted by Loess
Plot and add a smooth curve computed by
loess to a scatter plot.
scatter.smooth(x, y = NULL, span = 2/3, degree = 1, family = c("symmetric", "gaussian"), xlab = NULL, ylab = NULL, ylim = range(y, pred$y, na.rm = TRUE), evaluation = 50, ..., lpars = list())
loess.smooth(x, y, span = 2/3, degree = 1, family = c("symmetric", "gaussian"), evaluation = 50, ...)
- x, y
yarguments provide the x and y coordinates for the plot. Any reasonable way of defining the coordinates is acceptable. See the function
- smoothness parameter for
- degree of local polynomial used.
"gaussian"fitting is by least-squares, and if
family = "symmetric"a re-descending M estimator is used. Can be abbreviated.
- label for x axis.
- label for y axis.
- the y limits of the plot.
- number of points at which to evaluate the smooth curve.
scatter.smooth(), graphical parameters, passed to
loess.smooth, control parameters passed to
listof arguments to be passed to
loess.smooth is an auxiliary function which evaluates the
loess smooth at
evaluation equally spaced points
covering the range of
loess.smooth, a list with two components,
x(the grid of evaluation points) and
y(the smoothed values at the grid points).
require(graphics) with(cars, scatter.smooth(speed, dist)) ## or with dotted thick smoothed line results : with(cars, scatter.smooth(speed, dist, lpars = list(col = "red", lwd = 3, lty = 3)))