Try the 'rgl' package
On Tue, May 20, 2008 at 4:19 PM, <cgenolin@u-paris10.fr> wrote:
> Hi the list,
>
> I write a short function to draw lines in 3D, showing then turning.
> At some point, I add "delais" to slow down the rotation.
>
>
> So two questions:
>
> 1) I try to find a library to draw animate lines in 3D but I did not find.
> That surprise me since it is very simple to do. Did I forget to look
> somewhere ?
>
> If it does not exists and I have to use my own function :
> 2) Is it possible to use the time wasted in delais for some calculous ? In
> other word, can I run some calculous during a certain amount of time, then
> drawing a plot, then calculous then plot...
>
> 3) Is there a way to end the rotation less violant than Esc ?
>
> Thanks for your help.
>
> Here is my code :
>
>
> ----- 8< ---------------------------
> data <- array(c(13,14,13,15, 14,15,16,15, 16,17,16,18 , 45,46,85,59,
> 43,58,70,56, 45,75,65,65),
>
dim=c(4,3,2),dimnames=c("id","temps","var"))
>
> plot3Dlines <- function(x,y,mean=TRUE,angle=20,delais=100000,color,...){
> time <- 1:dim(x)[[2]]
> var1 <-
seq(min(x[,,1],na.rm=TRUE),max(x[,,1],na.rm=TRUE),length.out=11)
> var2 <- matrix(NA,length(time),length(var1))#outer(x, y, NA)
> var2[1,1] <- min(x[,,2],na.rm=TRUE)
> var2[length(time),length(var1)] <- max(x[,,2],na.rm=TRUE)
> nbLines<-min(100,dim(x)[1])
> if(missing(color)){color<-2:(nbLines+1)}else{}
> repeat{
> res <- persp(x=time, y=var1, z=var2, theta = angle,
> phi = 10, expand = 0.5, col = "lightblue",
> ltheta = 120, shade = 0.75, ticktype =
"detailed",
> xlab = "time", ylab = "var1", zlab =
"var2")
> angle <- angle+1
> for(i in 1:nbLines){
> yy=x[i,,1]
> zz=x[i,,2]
> lines (trans3d(time, yy, zz, pmat = res),col=color[i])
> }
> for(k in 1:delais){}
> }
> }
> plot3Dlines(data)
> ------------------------------------
>
> Thanks
>
> Christophe
>
> ______________________________________________
> 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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
[[alternative HTML version deleted]]