[R] Plotting a functional time series
Eduardo de Oliveira Horta
eduardo.oliveirahorta at gmail.com
Thu Feb 24 21:06:33 CET 2011
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)
#################################
Sorry for the mistake.
Best regards,
Eduardo
On Mon, Feb 21, 2011 at 11:18 PM, Eduardo de Oliveira Horta
<eduardo.oliveirahorta at 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 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.
>
More information about the R-help
mailing list