I'm have a (minor) problem and a question. Problem: The following code creates 5 clusters of dots of different colors. However, I need the second call outside the data.frame call to get the colors to change for some reason. I assume there's an error in the data.frame() call, but I don't know what. Question: Is there is a way to cause the resulting graphic to rotate on it's own and to output to a animated gif or some other format that could be used in a powerpoint type presentation? I work with a bunch of 'drama queens'--they'd like it if there was some motion rather than a static display ;-) Thanks in advance, Dale. library(rgl) clusset<-data.frame(x=c(round(abs(rnorm(5,7,1)),1),round(abs(rnorm(5,11,2)),1), round(abs(rnorm(5,16,2)),1),round(abs(rnorm(5,20,1.5)),1),round(abs(rnorm(5,5,2)),1)), y=c(round(abs(rnorm(5,7,2)),1),round(abs(rnorm(5,11,2)),1), round(abs(rnorm(5,16,2)),1),round(abs(rnorm(5,4,2)),1),round(abs(rnorm(5,7,2)),1)), z=c(round(abs(rnorm(5,7,2)),1),round(abs(rnorm(5,12,2)),1), round(abs(rnorm(5,16,1)),1),round(abs(rnorm(5,6,2)),1),round(abs(rnorm(5,17,2)),1)), dotcol=c(rep('red2',5),rep('green2',5),rep('blue2',5),rep('yellow1',5),rep('purple2',5)) ) #this call doesn't show the right colors--why? plot3d(clusset, xlim=c(0,25), ylim=c(0,25), zlim=c(0,25),xlab='',ylab='',zlab='', col=clusset$dotcol, radius=1, type='s') #but if I redefine the colors again and call, it does clusset$dotcol<-c(rep('red2',5),rep('green2',5),rep('blue2',5),rep('yellow1',5),rep('purple2',5)) plot3d(clusset, xlim=c(0,25), ylim=c(0,25), zlim=c(0,25),xlab='',ylab='',zlab='', col=clusset$dotcol, radius=1, type='s')
It seems like you have two questions, one about color rendering, and another about making animations. For the second question : I've found the animation package useful in similar situations, where I want to share results with non-R users who want a static visualization. By using animation you can create a HTML page that you can view by simply opening the html index page. There are some simple controls that can let you step through your animation manually or at a specific time interval. I also find that the brute force method of saving files and stepping through them is usually my best solution. My favorite thing though has been to use the PBSmodelling package. You can make a graph and a slider, and then you can interactively change the graph with the slider, they have many great demos in their package of how to create sliders. Also, the rpanel function is pretty nice for some simple work http://chartsgraphs.wordpress.com/2009/05/08/rpanel-package-adds-interactive-capabilites-to-r/ On Thu, Jul 28, 2011 at 3:14 PM, Dale Coons <dale.coons@gmail.com> wrote:> I'm have a (minor) problem and a question. > Problem: The following code creates 5 clusters of dots of different colors. > However, I need the second call outside the data.frame call to get the > colors to change for some reason. I assume there's an error in the > data.frame() call, but I don't know what. > Question: Is there is a way to cause the resulting graphic to rotate on > it's own and to output to a animated gif or some other format that could be > used in a powerpoint type presentation? I work with a bunch of 'drama > queens'--they'd like it if there was some motion rather than a static > display ;-) > > Thanks in advance, > Dale. > > library(rgl) > clusset<-data.frame(x=c(round(**abs(rnorm(5,7,1)),1),round(** > abs(rnorm(5,11,2)),1), > round(abs(rnorm(5,16,2)),1),** > round(abs(rnorm(5,20,1.5)),1),**round(abs(rnorm(5,5,2)),1)), > y=c(round(abs(rnorm(5,7,2)),1)** > ,round(abs(rnorm(5,11,2)),1), > round(abs(rnorm(5,16,2)),1),** > round(abs(rnorm(5,4,2)),1),**round(abs(rnorm(5,7,2)),1)), > z=c(round(abs(rnorm(5,7,2)),1)** > ,round(abs(rnorm(5,12,2)),1), > round(abs(rnorm(5,16,1)),1),** > round(abs(rnorm(5,6,2)),1),**round(abs(rnorm(5,17,2)),1)), > dotcol=c(rep('red2',5),rep('** > green2',5),rep('blue2',5),rep(**'yellow1',5),rep('purple2',5)) > ) > > #this call doesn't show the right colors--why? > plot3d(clusset, xlim=c(0,25), ylim=c(0,25), zlim=c(0,25),xlab='',ylab='',* > *zlab='', col=clusset$dotcol, radius=1, type='s') > #but if I redefine the colors again and call, it does > clusset$dotcol<-c(rep('red2',**5),rep('green2',5),rep('blue2'** > ,5),rep('yellow1',5),rep('**purple2',5)) > plot3d(clusset, xlim=c(0,25), ylim=c(0,25), zlim=c(0,25),xlab='',ylab='',* > *zlab='', col=clusset$dotcol, radius=1, type='s') > > ______________________________**________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/**listinfo/r-help<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. >[[alternative HTML version deleted]]
Dale, I do not have the same color problem when I run your code on my PC. The colors in both devices look the same. I'm running R version 2.13.0 on Windows. I am not familiar with the rgl package, but I found a function that might be helpful to you when I searched for "gif" in the package reference manual. ?movie3d() Hope this helps. Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA From: Dale Coons <dale.coons@gmail.com> To: r-help@r-project.org Date: 07/28/2011 03:22 PM Subject: [R] Animated gif or something similar in R? Sent by: r-help-bounces@r-project.org I'm have a (minor) problem and a question. Problem: The following code creates 5 clusters of dots of different colors. However, I need the second call outside the data.frame call to get the colors to change for some reason. I assume there's an error in the data.frame() call, but I don't know what. Question: Is there is a way to cause the resulting graphic to rotate on it's own and to output to a animated gif or some other format that could be used in a powerpoint type presentation? I work with a bunch of 'drama queens'--they'd like it if there was some motion rather than a static display ;-) Thanks in advance, Dale. library(rgl) clusset<-data.frame(x=c(round(abs(rnorm(5,7,1)),1),round(abs(rnorm(5,11,2)),1), round(abs(rnorm(5,16,2)),1),round(abs(rnorm(5,20,1.5)),1),round(abs(rnorm(5,5,2)),1)), y=c(round(abs(rnorm(5,7,2)),1),round(abs(rnorm(5,11,2)),1), round(abs(rnorm(5,16,2)),1),round(abs(rnorm(5,4,2)),1),round(abs(rnorm(5,7,2)),1)), z=c(round(abs(rnorm(5,7,2)),1),round(abs(rnorm(5,12,2)),1), round(abs(rnorm(5,16,1)),1),round(abs(rnorm(5,6,2)),1),round(abs(rnorm(5,17,2)),1)), dotcol=c(rep('red2',5),rep('green2',5),rep('blue2',5),rep('yellow1',5),rep('purple2',5)) ) #this call doesn't show the right colors--why? plot3d(clusset, xlim=c(0,25), ylim=c(0,25), zlim=c(0,25),xlab='',ylab='',zlab='', col=clusset$dotcol, radius=1, type='s') #but if I redefine the colors again and call, it does clusset$dotcol<-c(rep('red2',5),rep('green2',5),rep('blue2',5),rep('yellow1',5),rep('purple2',5)) plot3d(clusset, xlim=c(0,25), ylim=c(0,25), zlim=c(0,25),xlab='',ylab='',zlab='', col=clusset$dotcol, radius=1, type='s') ______________________________________________ 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. [[alternative HTML version deleted]]