savepng: Save the contents of the current graphics device to a file

View source: R/savepng.R

savepngR Documentation

Save the contents of the current graphics device to a file

Description

Save the contents of the current graphics device to file

Usage

  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, ...)

Arguments

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).

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.

Value

Character: name of the file that was written.

Author(s)

Wolfgang Huber http://www.dkfz.de/abt0840/whuber

See Also

dev.copy, pdf, png, postscript

Examples

  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
    c(
      savepdf("spiral", dir=tempdir()),
      savepng("spiral", dir=tempdir()),
      saveeps("spiral", dir=tempdir()),
      savetiff("spiral", dir=tempdir())
     )
  })    

Bioconductor/geneplotter documentation built on Nov. 2, 2024, 7:25 a.m.