
if (require("grid")) {
# we support arbitrary oblique projection angles
mat <- matrix(c(1, 2, 1, 2, 3, 2, 1, 2, 1), nrow = 3, ncol = 3, byrow = TRUE)
coords <- xyz_heightmap(mat, col = c("red", "yellow", "green"))
angles <- c(135, 90, 45, 180, 45, 0, -135, -90, -45)
scales <- c(0.5, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5)
vp_x <- rep(1:3/3 - 1/6, 3)
vp_y <- rep(3:1/3 - 1/6, each = 3)
grid.newpage()
for (i in 1:9) {
pushViewport(viewport(x=vp_x[i], y=vp_y[i], width=1/3, height=1/3))
grid.rect(gp = gpar(lty = "dashed"))
grid.oblicubes(coords, width = 0.15, xo = 0.25, yo = 0.15,
angle = angles[i], scale = scales[i],
gp = gpar(lwd=4))
if(i != 5)
grid.text(paste("angle =", angles[i]), y=0.92, gp = gpar(cex = 1.2))
else
grid.text(paste("scale = 0"), y=0.92, gp = gpar(cex = 1.2))
popViewport()
}
}
# volcano example
mat <- datasets::volcano
mat <- 0.3 * (mat - min(mat)) + 1.0
coords <- xyz_heightmap(mat, col = grDevices::terrain.colors)
grid::grid.newpage()
grid.oblicubes(coords)
Run the code above in your browser using DataLab