[R] Problems with png()

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Mon Sep 6 11:57:53 CEST 2004


Laura Quinn wrote:
> I am trying to save a series of plots as .png files by using
> 
> png(file="myfile.png",bg="transparent")
> dev.off()
> 
> for each image plot I produce. Unfortunately when I have tried this I am
> unable to open the files, and am told they are corrupted.
> 
> I have tried to use the jpeg() function but have the same problem. The only way I have managed to
> export a graphic successfully is as dev.copy2eps. Aside from producing
> unwieldy files, this is also unhelpful as I at m hoping to create a movie of
> the images via ImageMagick.
> 

  This sounds a bit obvious, but are you doing your plot commands 
_between_ the png() call and the dev.off() call?

  Try:

  png(file="foo.png")
  plot(1:10)
  dev.off()

  What version/platform are you using?

Barry




More information about the R-help mailing list