Thanks a lot! Regards,
Eduardo On Thu, Feb 24, 2011 at 6:47 PM, David Winsemius <dwinsem...@comcast.net> wrote: > > On Feb 24, 2011, at 3:06 PM, Eduardo de Oliveira Horta wrote: > >> It seems the code I've sent had typos... >> >> Here's a corrected version: >> >> ################################# >> x <- sapply(1:10, function(i)rnorm(1000)) >> f <- sapply(1:10, function(i)density(x[,i], from=-5,to=5)$y) >> grid <- density(x[,1], from=-5,to=5)$x >> win.graph() >> persp(grid, 1:10, f,theta=-50, phi=30, d=2) >> >> win.graph() >> opar <- par(mfrow=c(5,2), mar=c(2,2,1,1)) >> sapply(1:10, function(i)plot(grid, f[,i], ann=FALSE, type="l")) >> par(opar) >> ################################# > > This would put them all on one plot: > > x <- sapply(1:10, function(i)rnorm(1000)) > f <- sapply(1:10, function(i)density(x[,i], from=-5,to=5)$y) > grid <- density(x[,1], from=-5,to=5)$x > pdf() > persp(grid, 1:10, f,theta=-50, phi=30, d=2) > opar <- par(mfrow=c(5,2), mar=c(2,2,1,1)) > pdf() ; plot(grid, f[,1], ann=FALSE, type="l") #only one plot > sapply(2:10, function(i) lines(grid, f[,i])) # the rest with lines() > par(opar); dev.off() > > You could color code them with rainbow colors. There is also a lattice > example with such profiles stacked on top of each other ( in chapter 14 if I > remember correctly) and all the lattice examples are on the web at the book > site. Search on: > > sarkar lattice > >> >> Sorry for the mistake. >> >> Best regards, >> >> Eduardo >> >> On Mon, Feb 21, 2011 at 11:18 PM, Eduardo de Oliveira Horta >> <eduardo.oliveiraho...@gmail.com> wrote: >>> >>> Hello, >>> >>> I'm willing to plot a sequence of densities on a 3d graph, something like >>> >>> ----------------------------------------------------------------- >>> x <- sapply(1:10, function(i)rnorm(1000)) >>> >>> f <- sapply(1:10, function(i)density(x[,i], from=-5,to=5)$y) >>> grid <- density(x[,1], from=-5,to=5)$x >>> >>> win.graph() >>> persp(grid1, 1:10, f,theta=-50, phi=30, d=2) >>> ----------------------------------------------------------------- >>> >>> That is, I simply want to stack the curves >>> >>> ----------------------------------------------------------------- >>> win.graph() >>> opar <- par(mfrow=c(5,2), mar=c(2,2,1,1)) >>> sapply(1:10, function(i)plot(grid, f[,i], ann=FALSE, type="l")) >>> par(opar) >>> ----------------------------------------------------------------- >>> >>> into a functional time series plot (unlike the example above, I'm >>> working with pdf's which are not independent). >>> >>> The result I get using persp() is 'almost' what I want, but I would >>> like to avoid the wireframes connecting the densities along 1:10, >>> because there's no continuity in that direction. In other words, I >>> wanted that the only lines appearing in the plot to be those >>> corresponding to the pdf's f[,1],...f[,10]. >>> >>> Thanks once again, and best regards, >>> >>> Eduardo >>> >>>> sessionInfo() >>> >>> R version 2.11.1 (2010-05-31) >>> i386-pc-mingw32 >>> >>> locale: >>> [1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 >>> [3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C >>> [5] LC_TIME=Portuguese_Brazil.1252 >>> >>> attached base packages: >>> [1] stats graphics grDevices utils datasets methods base >>> >>> other attached packages: >>> [1] rgl_0.92.798 Revobase_4.2.0 RevoScaleR_1.1-1 lattice_0.19-13 >>> >>> loaded via a namespace (and not attached): >>> [1] grid_2.11.1 pkgXMLBuilder_1.0 revoIpe_1.0 tools_2.11.1 >>> [5] XML_3.1-0 >>> >>> ______________________________________________ >>> R-help@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >>> >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > David Winsemius, MD > West Hartford, CT > > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.