x <- rnorm(200, sd = 5)
y <- rnorm(200, sd = 5)
r <- sqrt(x^2 + y^2)
z <- 10 * sin(r)/r
col <- cm.colors(20)[1 + round(19*(z - min(z))/diff(range(z)))]
save <- options(rgl.meshColorWarning = FALSE)
# This code is awkward: to work with demo(rglExamples),
# we need auto-printing of the plots. This means we
# have to repeat the test for deldir.
haveDeldir <- checkDeldir()
if (haveDeldir) {
dxyz <- deldir::deldir(x, y, z = z, suppressMsge = TRUE)
persp3d(dxyz, col = col)
}
if (haveDeldir) {
open3d()
# Do it without smoothing and with a different orientation.
persp3d(dxyz, col = col, coords = c("z", "x", "y"), smooth = FALSE)
}
options(save)
Run the code above in your browser using DataLab