Re: [R] drawing lines in 3D (rotating them)

From: jim holtman <jholtman_at_gmail.com>
Date: Tue, 20 May 2008 16:40:47 -0400

Try the 'rgl' package

On Tue, May 20, 2008 at 4:19 PM, <cgenolin_at_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_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<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]]

______________________________________________
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.
Received on Tue 20 May 2008 - 20:46:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 20 May 2008 - 21:30:59 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive