I am in need of a way to increase the resolution of the png files created by saveHTML().
Here is a dummy script of what I am trying to do where in reality plot() is a number of nested loops:
x<-y<-rep(1,10)
saveHTML( for (i in 1:10){
plot.new()
plot.window(xlim=c(0,10),ylim=c(0,10))
plot(x[i],y[i])
}
,ani.dev="png",img.name="test",htmlfile="test")
A few things I have tried: 1) increase the animation size using ani.options(ani.height,ani.width) but I only get a larger grainy image. 2) call png() device inside the saveHTML expression and set the resolution there, but ultimately I dont get any figures. 3) call a new windows() device for plotting and setting the window size, but again this does not increase the resolution.
The most straight forward work-around that I came across is to create hi-res pngs and animate using ffmpeg. But I am not ready to re-work my script just yet.
Has anyone found a way to increase png resolution inside the saveHTML() function?
Instead of passing
ani.dev="png"
, you can passani.dev = function(...){png(res=75*grain,...)}
, wheregrain
is some number > 1. If you specify the optionsani.height
and/orani.width
and multiply these values by the same factorgrain
, then you effectively increase the pixel resolution of the output by this factor.N.B.: the default resolution
75
above might be machine dependent, I did not see it documented.