## =======================================================================
## perspective plots
## =======================================================================
persp3Drgl(z = volcano, contour = list(side = "zmax"))
# ribbon, in x--direction
V <- volcano[seq(1, nrow(volcano), by = 5),
seq(1, ncol(volcano), by = 5)] # lower resolution
ribbon3Drgl(z = V, ticktype = "detailed")
hist3Drgl(z = V, col = "grey", border = "black", lighting = TRUE)
if (FALSE) {
cutrgl() # select a rectangle
uncutrgl()
}
## =======================================================================
## scatter points
## =======================================================================
with(quakes, scatter3Drgl(x = long, y = lat, z = -depth,
colvar = mag, cex = 3))
plotdev() # plots same on oridinary device...
## =======================================================================
## 3D surface
## =======================================================================
M <- mesh(seq(0, 2*pi, length.out = 50),
seq(0, 2*pi, length.out = 50))
u <- M$x ; v <- M$y
x <- sin(u)
y <- sin(v)
z <- sin(u + v)
# alpha makes colors transparent
surf3Drgl(x, y, z, colvar = z, border = "black", smooth = TRUE,
alpha = 0.2)
## =======================================================================
## volumetric data
## =======================================================================
x <- y <- z <- seq(-4, 4, by = 0.2)
M <- mesh(x, y, z)
R <- with (M, sqrt(x^2 + y^2 + z^2))
p <- sin(2*R) /(R+1e-3)
slice3Drgl(x, y, z, colvar = p, col = jet.col(alpha = 0.5),
xs = 0, ys = c(-4, 0, 4), zs = NULL, d = 2)
Run the code above in your browser using DataLab