sp
is an abbreviation for
scatterplot
.scatterplot(x, ...)
## S3 method for class 'formula':
scatterplot(x, data, subset, xlab, ylab, legend.title, labels,
...)
## S3 method for class 'default':
scatterplot(x, y, smooth = TRUE,
spread = !by.groups, span = 0.5,
loess.threshold = 5, reg.line = lm,
boxplots = if (by.groups) "" else "xy",
xlab = deparse(substitute(x)), ylab = deparse(substitute(y)),
las = par("las"), lwd = 1, lwd.smooth = lwd, lwd.spread = lwd,
lty = 1, lty.smooth = lty, lty.spread = 2, labels,
id.method = "mahal",
id.n = if(id.method[1]=="identify") length(x) else 0,
id.cex = 1, id.col = palette()[1], log = "", jitter = list(),
xlim = NULL, ylim = NULL, cex = par("cex"),
cex.axis = par("cex.axis"),
cex.lab = par("cex.lab"), cex.main = par("cex.main"),
cex.sub = par("cex.sub"), groups, by.groups = !missing(groups),
legend.title = deparse(substitute(groups)),
ellipse = FALSE, levels = c(0.5, 0.95), robust = TRUE,
col = if (n.groups == 1) palette()[1:2] else rep(palette(),
length = n.groups),
pch = 1:n.groups, legend.plot = !missing(groups), reset.par = TRUE,
grid=TRUE, ...)
sp(...)
y ~ x
or
(to plot by groups) y ~ x | z
, where z
evaluates to a factor
or other variable dividing the data into groups.TRUE
(the default) a loess nonparametric regression line is
drawn on the plot.TRUE
(the default when there are no groups), a smoother is applied to
the root-mean-square positive and negative residuals from the loess line to display conditional spread and
asymmetry.loess.threshold
unique
values (default, 5) of y
.FALSE
not to plot a regression line."x"
a boxplot for x
is drawn below the plot;
if "y"
a boxplot for y
is drawn to the left of the plot;
if "xy"
both boxplots are drawn; set to ""
or FALSE
0
, ticks labels are drawn parallel to the
axis; set to 1
for horizontal labels (see par
).1
).lwd
).lwd
).1
, solid line).lty
).2
, broken line).id.n=0
for labeling no points. See
showLabels
for details of these arguments. If the plot uses
different colors for grlog
argument to plot
, to produce log axes.x
or y
or both, specifying jitter factors
for the horizontal and vertical coordinates of the points in the scatterplot. The
jitter
function is usNULL
, determined from the data.NULL
, determined from the data.TRUE
, regression lines are fit by groups.TRUE
data-concentration ellipses are plotted.c(.5, .95)
.TRUE
(the default) use the cov.trob
function in the MASS
package
to calculate the center and covariance matrix for the data ellipses.palette()[1]
for lines and palette()[2]
for points if there are
no groups, and successive colors for the groups if there are groups.par
).par
).TRUE
then a legend for the groups is plotted in the upper margin.TRUE
then plotting parameters are reset to their previous values
when scatterplot
exits; if FALSE
then the mar
and mfcol
parameters are
altered for the current plotting device. plot
.NULL
is returned invisibly.boxplot
,
jitter
,
scatterplotMatrix
, dataEllipse
,
cov.trob
,
showLabels
.scatterplot(prestige ~ income, data=Prestige, ellipse=TRUE)
scatterplot(prestige ~ income|type, data=Prestige, span=1)
scatterplot(vocabulary ~ education, jitter=list(x=1, y=1),
data=Vocab, id.n=0, smooth=FALSE)
scatterplot(infant.mortality ~ gdp, log="xy", data=UN, id.n=5)
scatterplot(infant.mortality ~ gdp, id.method="identify", data=UN)
Run the code above in your browser using DataLab