Background: I am trying to animate a rotating 3D scatter plot using the R lattice :: cloud () function. I create a sequence of PNG images in R, and then create an animated GIF from the sequence.
The problem is that the scale of the graph changes with rotation, so the animated cube, as it appears, grows and contracts.
Here is an example using only two graphs (based on one of the cloud examples):
library(lattice)
par.set <-
list(axis.line = list(col = "transparent"),
clip = list(panel = "off"))
print(cloud(Sepal.Length ~ Petal.Length * Petal.Width,
data = iris, cex = .8,
groups = Species,
screen = list(z = 0, x = 0, y = 0),
par.settings = par.set,
scales = list(col = "black")),
split = c(1,1,2,1), more = TRUE)
print(cloud(Sepal.Length ~ Petal.Length * Petal.Width,
data = iris, cex = .8,
groups = Species,
screen = list(z = 0, x = 0, y = 30),
par.settings = par.set,
scales = list(col = "black")),
split = c(2,1,2,1))
I would like the right plot to look the same size as the left plot. In this example, this is a little less. I do not need to use R or the :: cloud () lattice, but it is very close to what I want ...
Trying rgl, it looks like my copy of rgl is incompatible with my version of R. I update R when I have a minute:
> library(rgl)
> df <- data.frame(x=runif(10,0,1), y=runif(10,0,1), z=runif(10,0,1), color=round(runif(10,1,3)))
> plot3d(df$x, df$y, df$z, col=df$color, size=2, type='s')
> rgl.snapshot("C:\\pic.png", fmt="png", top=TRUE )
[1] "failed"
Warning messages:
1: In rgl.snapshot("C:\\pic.png", fmt = "png", top = TRUE) :
RGL: PNG Pixmap Saver Warning: Application was compiled with png.h from libpng-1.2.40
2: In rgl.snapshot("C:\\pic.png", fmt = "png", top = TRUE) :
RGL: PNG Pixmap Saver Warning: Application is running with png.c from libpng-1.4.1
3: In rgl.snapshot("C:\\pic.png", fmt = "png", top = TRUE) :
RGL: PNG Pixmap Saver Warning: Incompatible libpng version in application and library
> sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgl_0.92.798
loaded via a namespace (and not attached):
[1] tools_2.11.1
R 2.12.2, ( GraphicsMagick ImageMagick):
open3d()
with(iris, plot3d(Petal.Length, Petal.Width, Sepal.Length, col=Species))
movie3d(spin3d(), duration=12, dir="C:\\Movie", convert=FALSE)
system('"C:\\program files\\graphicsmagick-1.3.7-q8\\gm.exe" convert -delay 12 C:\\Movie\\movie*.png C:\\Movie\\animate.gif')