System$findGraphicsDevice

0th

Percentile

Searches for a working PNG device

Searches for a working PNG device.

On Unix, the png device requires that X11 is available, which it is not when running batch scripts or running R remotely. In such cases, an alternative is to use the bitmap() device, which generates an EPS file and the uses Ghostscript to transform it to a PNG file.

Moreover, if identical looking bitmap and vector graphics (EPS) files are wanted for the same figures, in practice, bitmap() has to be used.

By default, this method tests a list of potential graphical devices and returns the first that successfully creates an image file. By default, it tries to create a PNG image file via the built-in png() device.

Keywords
methods, internal, device
Usage
## Static method (use this):
## System$findGraphicsDevice(devices=list(png), maxCount=100, sleepInterval=0.1,
##   findGhostscript=TRUE, ...)

## Don't use the below: # S3 method for System findGraphicsDevice(static, devices=list(png), maxCount=100, sleepInterval=0.1, findGhostscript=TRUE, ...)

Arguments
devices

A list of graphics device driver functions to be tested.

maxCount

The maximum number of subsequent tests for the the existences of bitmap() generated image files.

sleepInterval

The time in seconds between above subsequent tests.

findGhostscript

If TRUE, Ghostscript, which is needed by the bitmap() device, is searched for on the current system. If found, its location is recorded.

...

Not used.

Value

Returns a function that generates images, or NULL.

See Also

For supported graphical devices, see capabilities(). png, bitmap() and dev2bitmap. *findGhostscript(). For more information see System.

Aliases
  • System$findGraphicsDevice
  • findGraphicsDevice.System
  • System.findGraphicsDevice
  • findGraphicsDevice,System-method
Examples
# NOT RUN {
  fcn <- System$findGraphicsDevice()
  if (identical(fcn, png)) {
    cat("PNG device found: png()")
  } else if (identical(fcn, bitmap)) {
    cat("PNG device found: bitmap()")
  } else {
    cat("PNG device not found.")
  }
# }
Documentation reproduced from package R.utils, version 2.8.0, License: LGPL (>= 2.1)

Community examples

Looks like there are no examples yet.