Increase png resolution when using saveHTML () {animation} in R

I need a way to increase the resolution of png files created by saveHTML ().

Here is a mock script of what I am trying to do, where actually plot () is the 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")

      

Several things I've tried: 1) increase the size of the animation with ani.options (ani.height, ani.width) but I only get a large grainy image. 2) call png () device inside the saveHTML statement and set the resolution there, but I end up not getting any numbers. 3) call a new window () to plot the graph and set the window size, but again this does not increase the resolution.

The most straight forward job I've come across is to create a hi-res png and animate with ffmpeg. But I'm not ready to re-work with my script just yet.

Has anyone found a way to increase the png resolution inside the saveHTML () function?

+3


source to share


1 answer


Instead of transmitting, ani.dev="png"

you can pass ani.dev = function(...){png(res=75*grain,...)}

, where grain

is some number> 1. If you specify options ani.height

and / or ani.width

and multiply these values ​​by the same factor grain

, then you effectively increase the resolution of the pixels at the output by this factor.



NB: the default resolution 75

above may be machine dependent, I have not seen documented it.

0


source







All Articles