[R] Questions about png() on Windows

Johannes Schnitzler schnitzlerj at gmx.de
Sun Sep 14 13:22:43 CEST 2003


Thank you for the reply,
it is not essential that the format is png. Every format that can be
displayed in a web browser would be fine.

> > for an interactive web application i need to produce a lot of graphics
> (up
> > to 50) on demand.
> > In the moment i'm using the png format.
> > 
> > The png()
> > ...using png(file="Rplot%03d.png", ...); 'plots' ; dev.off()... 
> > produces very good graphics. The problem is it takes too long to produce
> the
> > png files.
> > The bitmap()
> > ...using bitmap(file="Rplot%03d.png", type="type = "png256",...);
> 'plots';
> > dev.off()...
> > works really fast. But on my system the quality is poor compared with
> png()
> > even with a higher resolution than 72.
> > 
> > I'm using R 1.7.0 on Windows NT ; Ghostscript 8.00
> > 
> > 1) Is there a possibility to speed up the png() 
> >     or to improve the quality of the png produced by bitmap()
> 
> There is a possibility.  You have the source code, and we would be happy 
> for you to optimize it and submit a faster version.  It looks up pixel 
> values one at a time, and the use of block operations should speed it up.

I don't think i have the ability (in the moment) to do so - but i will have
a try....
Meanwhile: has somebody experience in improving the quality by setting
different parameters?

> > 2) How is it possible to give "names" to the png files (if producing
> more
> > than one plot) instead of Name+serial number like Rplot%03d.png 
> 
> Just start a new device for each plot!

To open a new device every time slows it down again.
On my sytem:
system.time({
for(i in
1:50){xy<-paste(i,".png",sep="");bitmap(xy);plot(rnorm(100));dev.off()}
})
[1]  4.40  5.62 42.70    NA    NA

system.time({
bitmap("%03d.png");for(i in 1:50){plot(rnorm(100))};dev.off()
})
[1] 0.62 0.16 1.49   NA   NA

Thank you in advance

Johannes




More information about the R-help mailing list