savepng {geneplotter}R Documentation

Save the contents of the current graphics device to a file


Save the contents of the current graphics device to file


  savepdf(fn, dir, width=6, asp=1)
  saveeps(fn, dir, width=6, asp=1) 
  savepng(fn, dir, width=480, asp=1)
  savetiff(fn, dir, density=360, keeppdf=TRUE, ...)


fn character: name of the output file (without extension). An extension .pdf, .eps, .png, or .tiff will be added automatically.
dir character: directory to which the file should be written.
width numeric: width of the image in pixels (png) or inches (pdf, eps).
asp numeric: aspect ratio; height=width*asp.
density pixels per inch (see Details).
keeppdf Should the intermediate PDF file (see Details) be kept? If FALSE, it is deleted before the function returns.
... Further arguments that are passed on to savepdf (see Details).


The functions are called for their side effect, writing a graphics file.

savepdf, savepng, and saveeps use the devices pdf, png, and postscript, respectively.

There is currently no TIFF device for R, so savetiff works differently. It relies on the external tool convert from the ImageMagick software package. First, savetiff produces a PDF files with savepdf, then uses system to invoke convert with the parameter density. savetiff does not check for the existence of convert or the success of the system call, and returns silently no matter what.


Character: name of the file that was written.


Wolfgang Huber

See Also

dev.copy, pdf, png, postscript


  x = seq(0, 20*pi, len=1000)
  plot(x*sin(x), x*cos(x), type="l")

  try({   ## on some machines, some of the devices may not be available
      savepdf("spiral", dir=tempdir()),
      savepng("spiral", dir=tempdir()),
      saveeps("spiral", dir=tempdir()),
      savetiff("spiral", dir=tempdir())

[Package geneplotter version 1.8.0 Index]