384X21 384X21 - 5 months ago 20
Linux Question

How to increase resolution of gif image?

How to increase resolution of gif image generated by rgl package of R (plot3d and movie3d functions) - either externally or through R ?

R Code :

MyX<-rnorm(10,5,1)
MyY<-rnorm(10,5,1)
MyZ<-rnorm(10,5,1)
plot3d(MyX, MyY, MyZ, xlab="X", ylab="Y", zlab="Z", type="s", box=T, axes=F)
text3d(MyX, MyY, MyZ, text=c(1:10), cex=5, adj=1)
movie3d(spin3d(axis = c(0, 0, 1), rpm = 4), duration=15, movie="TestMovie",
type="gif", dir=("~/Desktop"))


Output :

Output
Update

Adding this line at the beginning of code solved the problem

r3dDefaults$windowRect <- c(0, 100, 1400, 1400)

Answer

I don't think you can do much about the resolution of the gif itself. I think you have to make the image much larger as an alternative, and then when you display it smaller it looks better. This is untested as a recent upgrade broke a thing or two for me, but this did work under 2.15:

par3d(windowRect = c(0, 0, 500, 500)) # make the window large
par3d(zoom = 1.1) # larger values make the image smaller

# you can test your settings interactively at this point

M <- par3d("userMatrix") # save your settings to pass to the movie

movie3d(par3dinterp(userMatrix=list(M,
    rotate3d(M, pi, 1, 0, 0), 
    rotate3d(M, pi, 0, 1, 0) ) ), 
    duration = 5, fps = 50,
    movie = "MyMovie")

HTH. If it doesn't quite work for you, check out the functions used and tune up the settings.

Comments