Learn R Programming

car (version 0.8-1)

scatterplot: Scatterplots with Boxplots

Description

Makes fancy scatterplots, with boxplots in the margins, a lowess smooth, and a regression line; sp is an abbreviation for scatterplot.

Usage

scatterplot(x, ...)

scatterplot.formula(formula, data, xlab, ylab, subset, labels=F, ...)

scatterplot.default(x, y, smooth=T, span=0.5, reg.line=lm, 
  boxplots="xy", xlab=deparse(substitute(x)), ylab=deparse(substitute(y)), 
  las=1, lwd=1, labels=F, log="", groups=FALSE, by.groups=!(groups == FALSE), 
  col=palette(), pch=1:n.groups, legend.plot=length(levels(groups)) > 1, ...)
  
sp{...}

Arguments

formula
``model'' formula, of the form y ~ x or (to plot by groups) y ~ x | z, where z evaluates to a factor or other variable dividing the data into groups.
data
data frame within which to evaluate the formula.
subset
expression defining a subset of observations.
x
vector of horizontal coordinates.
y
vector of verical coordinates.
smooth
if TRUE a lowess nonparametric regression line is drawn on the plot.
span
span for the lowess smooth.
reg.line
function to draw a regression line on the plot or FALSE not to plot a regression line.
boxplots
if "x" a boxplot for x is drawn above the plot; if "y" a boxplot for y is drawn to the right of the plot; if "xy" both boxplots are drawn.
xlab
label for horizontal axis.
ylab
label for vertical axis.
las
if 0, ticks labels are drawn parallel to the axis; set to 1 (the default) for horizontal labels (see par).
lwd
width of plotted lines.
labels
if not FALSE a vector of point labels, to be used interactively to identify points on the plot.
log
same as the log argument to plot, to produce log axes.
groups
a factor or other variable dividing the data into groups; groups are plotted with different colors and plotting characters.
by.groups
if TRUE, regression lines are fit by groups.
ellipse
if TRUE data-concentration ellipses are plotted in the off-diagonal panels.
levels
levels or levels at which concentration ellipses are plotted; the default is c(.5, .9).
robust
if TRUE use the cov.trob function in the MASS package to calculate the center and covariance matrix for the data ellipse.
col
colors for points and lines; the default is the in the current color palette, starting at the second entry (see palette and par).
pch
plotting characters for points; default is the plotting characters in order (see par).
legend.plot
if TRUE then a legend for the groups is plotted, and positioned interactively with a mouse click; if points are to be labelled, then the legend is positioned first.
...
other arguments passed to plot.

Value

  • NULL. This function is used for its side effect: producing a plot.

See Also

plot, boxplot, scatterplot.matrix, data.ellipse, cov.trob.

Examples

Run this code
data(Prestige)
scatterplot(prestige~income|type, data=Prestige, span=1, legend=F)
  data(UN)
scatterplot(infant.mortality~gdp, labels=row.names(UN), data=UN)

scatterplot(infant.mortality~gdp, log="xy", labels=row.names(UN), data=UN)

Run the code above in your browser using DataLab