[R] create a '3D line plot'

David Winsemius dwinsemius at comcast.net
Sun Sep 12 17:31:10 CEST 2010


On Sep 12, 2010, at 10:12 AM, Karl Brand wrote:

> Esteemed useRs and developeRs,
>
> I need to create a  '3D line plot' (proper name?) of which an  
> excellent example can be viewed here:
>
> http://cococubed.asu.edu/images/87a/images/unknown_pleasures.jpg

Set up blank plot region with proper ranges for x and ylim that could  
be say 0:60 with the intent of scaling your 50 individual y ranges to  
0-10
Scale your y values to be within 0-10
Fill plot area black:
Draw "from top down" using polygon with white lines at cex=2 and black  
fill.
Then something along these lines:
for(ilevel in 0:50){ polygon(x,yscaled+50-ilevel, col="black",  
border="white", lwd=2)}

#--- tested code----
opar <- par(bg="black")
  set.seed(1)
  Ldens <- vector(mode="list", 50)
  for(i in 1:50) {
    Ldens[[i]] <- density(rnorm(100), from=-3,to=3)
   with(Ldens[[i]], polygon(x=c(x[c(1, 1:512, 512)]), y= c(0, 50-i 
+20*y[1:512], 0),
                        col="black", border="white"))
  }
par(opar)
#-------------


Got any data?

-- 
David.


>
> I have some experience using the rgl package to create 3D PCA plots,  
> but have no idea where to start for an image like this.
>
> I'd really appreciate suggestions & help on how might achieve this  
> using R,
>
> Karl
>
> -- 
> Karl Brand
-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list