graphic-devices: Create a group of named graphic devices

graphic-devicesR Documentation

Create a group of named graphic devices

Description

Create a group of named graphic devices

Usage

dev_create(..., env = parent.frame(), attributes = list())

get_dev_attr(which, dev = grDevices::dev.cur(), ifnotfound = NULL)

Arguments

...

named expressions to launch devices

env

environment to evaluate expressions

attributes

named list; names correspond to device names and values are attributes to set to the devices

which

which attribute to obtain

dev

which device to search for attributes

ifnotfound

value to return if attribute is not found

Value

A list of functions to query, control, and switch between devices

Examples

## Not run:  ## Unix-specific example

# Create multiple named devices, setting attributes to the second graph
devs <- dev_create(
  line = X11(), points = x11(),
  attributes = list(points = list(pch = 16))
)

# switch to device named "points"

devs$dev_which('points')

# Plot points, with pch given as preset
plot(1:10, pch = get_dev_attr(which = 'pch', ifnotfound = 1))

# switch to "line" device
devs$dev_switch('line')
plot(1:100, type='l')

# Create another group with conflict name
dev_another <- dev_create(line = X11())

# Query device name with 'line'
dev_another$dev_which('line')  # 4
devs$dev_which('line')  # 2, doesn't conflict with the new groups

dev.list()
# close one or more device
dev_another$dev_off('line')
dev.list()

# close all devices
devs$dev_off()
dev.list()


## End(Not run)

dipsaus documentation built on June 27, 2024, 5:10 p.m.