cloud {lattice}R Documentation

3d Scatter Plot

Description

Draws 3d scatter plots. The default panel and prepanel function makes the necessary 3d to 2d transformations and draws the bounding box and the scales. The transformed points are then passed to the subpanel function which actually plots them. See details below for shortcomings.

Usage

cloud(formula,
      data,
      subpanel = "panel.xyplot",
      aspect = c(1, 1),
      scales = list(cex = 0.5, lty = 1, lwd = 1,
                    col = "black", distance = rep(1, 3),
                    arrows = TRUE, draw = TRUE),
      zlab,
      zlim = range(z), 
      distance = 0.2,
      par.box,
      perspective = TRUE,
      R.mat = diag(4), 
      screen = list(z = 40, x = -60),
      zoom = .9,
      ...)
wireframe(formula, data,
          at = pretty(z, cuts),
          col.regions,
          drape = FALSE,
          pretty = FALSE,
          colorkey = any(drape),
          cuts = 70,
          distance = 0.2,
          par.box,
          screen = list(z = 40, x = -60),
          zoom = .9,
          scales = list(cex = 0.5, distance = rep(1, 3), arrows = TRUE),
          ...)

Arguments

formula a formula of the form z ~ x * y | g1 * g2 * ...
data data frame in which variables are evaluated
subpanel the function used to plot the points in cloud once coordinates of their projections are computed. subpanel="panel.superpose" along with the groups argument can be used to create grouped displays. See iris example below
aspect vector of length 2, giving the relative aspects of the y-size/x-size and z-size/x-size of the enclosing rectangle.
scales describes scales. Can contain lists named x, y and z. Arrows are drawn if arrows=TRUE, otherwise tick marks with labels are drawn. Both can be suppressed by draw=FALSE. Several other components that work in the usual scales argument also work here.
zlab z label
zlim z limits
distance between 0 and 1, controls amount of perspective. No connection with the physical concept of distance in this implementation (not clear what S+ does). individual values don't give the same results as S-Plus, but all instances should be achievable.
par.box graphical parameters for box, namely, col, lty and lwd. By default obtained from the parameter box.3d
perspective logical, whether to plot a perspective view
R.mat initial rotation matrix (homogeneous coordinates). Currently ignored.
screen A list determining the rotations to applied to the data before being plotted. The initial position starts with the view somewhere in the positive z-axis, and the x and y axes in the usual position. Each component of the list should be named one of x, y, z, with their values indicating the amount of rotation about that axis in degrees.
zoom factor by which to scale the picture.
drape whether the wireframe is to be draped in color
at these arguments are analogous to those in levelplot. if drape=TRUE, at gives the vector of values where the colors change
col.regions the vector of colors to be used in that case
cuts the default number of cutpoints if drape=TRUE
pretty whether the cutpoints should be pretty
colorkey whether a color key should be drawn alongside. See levelplot for details
... other arguments

Details

cloud draws a 3d Scatter Plot, while wireframe draws a wireframe 3d surface. wireframe is very much in a proof of concept stage, and is extremely slow in rendering; this should improve sometime in the future.

The R.mat argument is currently ignored, and there are no plans to implement it in the near future.

The algorithm for identifying which edges of the bounding box should be drawn before the points are plotted fails in some cases.

Of the four possible edges that correspond to the x-axis, any one can be chosen as the one along which the arrows or tick marks are to be drawn. However, the default choice is not always a good choice, and might need to be overridden. See help for panel.cloud for details. The same holds for y and z axes as well.

This and all other high level Trellis functions have several arguments in common. These are extensively documented only in the help page for xyplot, which should be consulted to learn more detailed usage.

Author(s)

Deepayan Sarkar deepayan@stat.wisc.edu

See Also

xyplot, levelplot, panel.cloud, Lattice

Examples

x <- seq(-pi, pi, len = 20)
y <- seq(-pi, pi, len = 20)
g <- expand.grid(x = x, y = y)
g$z <- sin(sqrt(g$x^2 + g$y^2))
wireframe(z ~ x * y, g, drape = TRUE, col.regions = "white",
          aspect = c(3,1), colorkey = FALSE)
data(iris)
cloud(Sepal.Length ~ Petal.Length * Petal.Width, data = iris,
      groups = Species, screen = list(z = 20, x = -70),
      subpanel = panel.superpose,
      key = list(title = "Iris Data", x = .15, y=.85, corner = c(0,1),
                 border = TRUE, 
                 points = Rows(trellis.par.get("superpose.symbol"), 1:3),
                 text = list(levels(iris$Species))))
print(cloud(Sepal.Length ~ Petal.Length * Petal.Width, 
            data = iris, cex = .8, perspective = FALSE,
            groups = Species, 
            subpanel = panel.superpose,
            main = "Stereo",
            screen = list(z = 20, x = -70, y = 3)),
      split = c(1,1,2,1), more = TRUE)
print(cloud(Sepal.Length ~ Petal.Length * Petal.Width,
            data = iris, cex = .8, perspective = FALSE,
            groups = Species,
            subpanel = panel.superpose,
            main = "Stereo",
            screen = list(z = 20, x = -70, y = 0)),
      split = c(2,1,2,1))

[Package Contents]