Skip to content
Prev 59526 / 398502 Next

3d Map with bars

Try something like this:

library(maps)
states <- map("state", plot=F)
x1 <- rep(0, 3)
x2 <- rep(0, 3)
maxz <- 1
z <- matrix(c(0, 0, 0, 0, 0, 0, maxz, maxz, maxz), 3, 3)
x1[-2] <- states$range[1:2]
x2[-2] <- states$range[3:4]
x1[2] <- x1[3] - 1e-6
x2[2] <- x2[3] - 1e-6
pmat <- persp(x1, x2, z, xlab = "", ylab = "", zlab="", axes = F,
  theta=0, phi=20, d=10)
lines(trans3d(states$x, states$y, 0, pmat))
latitude <- -90
longitude <- 37
myz <- 0.6
lines(trans3d(rep(latitude, 2), rep(longitude, 2), c(0, myz), pmat), col=2)

where trans3d is as defined in the examples for persp().

Hope this helps,
Ray Brownrigg

----