Is there any way to input a fixed vector of colours to any 3D rgl
plots? If so it would be possible to extrude a map tile to a 3D surface based on a raster of the same area. But I'm finding the surface3d
function behaves the same as raster::plot
by insisting on mapping the input colour vector to the z variable. Is this beyond rgl's functionality at present?
Asked
Active
Viewed 88 times
0

geotheory
- 22,624
- 29
- 119
- 196
1 Answers
2
I don't actually know if what you say about the coloring is correct for all rgl coloring functions, but it is not correct for rgl.surface()
. This is a corruption of the example on the ?rgl.surface
page. The color vector index was formed from the x-y (actually x-z) coordinates and gives a striping effect because they were modulo-ized to pull values from from a limited range.
library(rgl)
data(volcano)
y <- 2 * volcano
x <- 10 * (1:nrow(y))
z <- 10 * (1:ncol(y))
ylim <- range(y)
ylen <- ylim[2] - ylim[1] + 1
colorlut <- terrain.colors(ylen)
col <- colorlut[(x+length(x)*y +1)%%ylen ]
rgl.open()
rgl.surface(x, z, y, color=col, back="lines")
rgl.snapshot("striped_volcano.png")

IRTFM
- 258,963
- 21
- 364
- 487
-
Thanks Bonded that's most helpful – geotheory Aug 27 '14 at 11:36