autoplay: Set playwith to run automatically.

Description Usage Arguments Details Author(s) See Also Examples

Description

Set playwith to run automatically with Lattice graphics and/or base graphics.

Usage

1
autoplay(on = NA, lattice.on = on, base.on = on, grid.on = on, ask = FALSE)

Arguments

on

TRUE to set playwith to run automatically to display Lattice and base graphics. FALSE to revert to the default plot device (i.e. getOption("device")).

lattice.on

run automatically to display Lattice graphics.

base.on

run automatically to display base graphics (plot etc).

grid.on

run automatically to display grid graphics (except Lattice).

ask

if TRUE, select the appropriate plot call from a list (the call stack) when automatically starting a base graphics plot.

Details

When lattice.on is TRUE, the print.trellis function, which is typically called implicitly to create lattice plots, will trigger playwith, passing the original high-level call. So for lattice plots only, this is like changing your default plot device. It only replaces the screen device: plotting to a file device will work as normal. This feature requires lattice package version 0.17-1 or later.

When base.on is TRUE, any new base graphics plot will trigger playwith (via a hook in plot.new), and the high-level plot call is taken to be the first call (to a named function) on the call stack. The usual base graphics paradigm of building up a plot incrementally will not work well, because only the initial plot call is recorded, so any further additions will be lost when the plot is redrawn. For similar reasons, multiple-figure plots may not be redrawn correctly. The high-level plot will be called twice initially, due to constraints of the mechanism.

The grid.on argument is analogous to base.on for grid graphics, using a hook in grid.newpage.

Note that this automatic behaviour is not a full replacement for calling playwith directly, since it does not allow to you specify any of the optional arguments.

Another possibility is options(device="playwith"). This will act as a default device but without most of the interactive features. The plot can still be annotated with text and arrows in this case.

Author(s)

Felix Andrews felix@nfrac.org

See Also

playwith

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if (interactive()) {

## lattice graphics in the playwith interface:
autoplay(lattice=T)
xyplot(Sepal.Length ~ Sepal.Width | Species, data=iris)

dev.off()

## lattice graphics in your usual screen device:
autoplay(lattice=F)
xyplot(Sepal.Length ~ Sepal.Width | Species, data=iris)

## base graphics in the playwith interface:
autoplay(TRUE)
frog <- rnorm(64)
hist(frog)

dev.off()

## base graphics in your usual screen device:
autoplay(FALSE)
hist(frog)

}

11010tianyi/playwith documentation built on May 5, 2019, 10:37 a.m.