[R] Plotting a functional time series

David Winsemius dwinsemius at comcast.net
Thu Feb 24 22:31:10 CET 2011


I'm not a Windows user, but if win.graph is like other output  device  
calls, it would need a dev.off() to close it. When I do it with pdf()  
and close with dev.off() I get ten pages, each with a density that is  
consistent with what should be seen with rnorm() as input.


-- 
David.

On Feb 21, 2011, at 9:18 PM, Eduardo de Oliveira Horta 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 at 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



More information about the R-help mailing list