scatter.smooth
Scatter Plot with Smooth Curve Fitted by Loess
Plot and add a smooth curve computed by loess
to a scatter plot.
- Keywords
- smooth
Usage
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, ...)
Arguments
- x, y
- the
x
andy
arguments provide the x and y coordinates for the plot. Any reasonable way of defining the coordinates is acceptable. See the functionxy.coords
for details. - span
- smoothness parameter for
loess
. - degree
- degree of local polynomial used.
- family
- if
"gaussian"
fitting is by least-squares, and iffamily = "symmetric"
a re-descending M estimator is used. Can be abbreviated. - xlab
- label for x axis.
- ylab
- label for y axis.
- ylim
- the y limits of the plot.
- evaluation
- number of points at which to evaluate the smooth curve.
- ...
- For
scatter.smooth()
, graphical parameters, passed toplot()
only. Forloess.smooth
, control parameters passed toloess.control
. - lpars
- a
list
of arguments to be passed tolines()
.
Details
loess.smooth
is an auxiliary function which evaluates the
loess
smooth at evaluation
equally spaced points
covering the range of x
.
Value
-
For
scatter.smooth
, none.For loess.smooth
, a list with two components, x
(the
grid of evaluation points) and y
(the smoothed values at the
grid points).
See Also
loess
; smoothScatter
for scatter plots
with smoothed density color representation.
Examples
library(stats)
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)))
Community examples
Looks like there are no examples yet.