[R] Re: 3d Map with bars

Ray Brownrigg ray at mcs.vuw.ac.nz
Mon Nov 22 00:38:47 CET 2004


> From: partha_bagchi at hgsi.com
> Date: Fri, 19 Nov 2004 16:53:12 -0500
> 
> Thanks for reply. I need to first draw the map of USA a perspective plot. 
> I guess thats where my problem was.
> 

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

----
> Uwe Ligges <ligges at statistik.uni-dortmund.de>
> 11/19/2004 04:33 PM
> 
>         To:     partha_bagchi at hgsi.com
>         cc:     r-help at stat.math.ethz.ch
>         Subject:        Re: 3d Map with bars
> 
> 
> partha_bagchi at hgsi.com wrote:
> 
> > Apologies in advance for the question. I am trying to draw a map of the 
> US
> > as a surface plot so that I would be able to drop bars on the different
> > states (something like Uwe Ligges' scatterplot3d example 4). I am not 
> sure
> > where to start looking for such a beast. If anyone has any pointers,
> > ideas, I will be grateful.
> >
> > TIA,
> > Partha
> 
> How to "drop bars" with persp() has been described on R-help yesterday
> or today, please check the mailing list's archives.
>




More information about the R-help mailing list