scatter3dHH | R Documentation |
The scatter3d
function uses the rgl
package to draw 3D scatterplots
with various regression surfaces. The function Identify3d
allows you to label points interactively with the mouse:
Press the right mouse button (on a two-button mouse) or the centre button (on a
three-button mouse), drag a
rectangle around the points to be identified, and release the button.
Repeat this procedure for each point or
set of “nearby” points to be identified. To exit from point-identification mode,
click the right (or centre) button an empty region of the plot.
This is a revision of the Rcmdr
scatter3d
to add the
ability to plot squared residuals.
scatter3dHH(x, y, z,
xlab=deparse(substitute(x)), ylab=deparse(substitute(y)),
zlab=deparse(substitute(z)),
revolutions=0, bg.col=c("white", "black"),
axis.col=if (bg.col == "white") "black" else "white",
surface.col=c("blue", "green", "orange", "magenta",
"cyan", "red", "yellow", "gray"),
neg.res.col="red", pos.res.col="green", point.col="yellow",
text.col=axis.col,
grid.col=if (bg.col == "white") "black" else "gray",
fogtype=c("exp2", "linear", "exp", "none"),
residuals=(length(fit) == 1), surface=TRUE, grid=TRUE,
grid.lines=26, df.smooth=NULL, df.additive=NULL,
sphere.size=1, threshold=0.01, speed=1, fov=60,
fit="linear", groups=NULL, parallel=TRUE, model.summary=FALSE,
squares = FALSE, square.color = "gray", coef.ratio = 1, ...)
x |
variable for horizontal axis. |
y |
variable for vertical axis (response). |
z |
variable for out-of-screen axis. |
xlab , ylab , zlab |
axis labels. |
revolutions |
number of full revolutions of the display. |
bg.col |
background colour; one of |
axis.col |
colour for axes; default is |
surface.col |
vector of colours for regression planes,
used in the order specified by |
neg.res.col , pos.res.col |
colours for lines representing negative and positive residuals. |
point.col |
colour of points. |
text.col |
colour of axis labels. |
grid.col |
colour of grid lines on the regression surface(s). |
fogtype |
type of fog effect; one of |
residuals |
plot residuals ( |
surface |
plot surface(s) ( |
grid |
plot grid lines on the regression surface(s) ( |
grid.lines |
number of lines (default, 26) forming the grid, in each of the x and y directions. |
df.smooth |
degrees of freedom for the two-dimensional smooth regression surface;
if |
df.additive |
degrees of freedom for each explanatory variable in an additive regression;
if |
sphere.size |
relative sizes of spheres representing points; the actual size is dependent on the number of observations. |
threshold |
if the actual size of the spheres is less than the threshold, points are plotted instead. |
speed |
relative speed of revolution of the plot. |
fov |
field of view (in degrees); controls degree of perspective. |
fit |
one or more of |
groups |
if |
parallel |
when plotting surfaces by |
model.summary |
print summary or summaries of the model(s) fit
( |
col |
colours for the point labels, given by group. There must be at
least as many colours as groups; if there are no groups, the first colour is used. Normally, the colours
would correspond to the |
squares |
logical. If |
square.color |
color for the squares. |
coef.ratio |
number, defaults to 1. Settig |
... |
other arguments are ignored. |
scatter3d
not return a useful value; it is used for its side-effect of
creating a 3D scatterplot. Identify3d
returns the labels of the
identified points.
You have to install the rgl
and mgcv
packages to produce 3D plots.
John Fox jfox@mcmaster.ca. Squared residuals added by Richard M. Heiberger <rmh@temple.edu>.
rgl.open
, gam
## Not run:
State.x77 <- as.data.frame(state.x77)
with(State.x77, scatter3d(Income, Murder, Illiteracy))
with(State.x77, Identify3d(Income, Murder, Illiteracy, labels=row.names(State.x77)))
with(State.x77, scatter3d(Income, Murder, Illiteracy, fit=c("linear", "quadratic")))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.