plotAndPlay {plotAndPlayGTK} | R Documentation |
Open a GTK window to view and interact with a plot.
plotAndPlay(expr, name = "plot", plot.call, nav.scales = c("x","y"), trans.scales = c("y"), buttons = plotAndPlayButtons[c("identify", "zoomin", "zoomout", "zoomfit", "centre")], extra.buttons = plotAndPlayButtons[c("zero")], labels = NULL, identify.call = NULL, is.lattice = (callName %in% latticeNames), eval.args.pattern = ".", envir = parent.frame()) plotAndPlayButtons
expr |
an expression to create a plot, like plot(1:10) (see examples). |
name |
character value to identify the plot window. |
plot.call |
a plot call ( call object), if given this is used instead of expr . |
nav.scales |
one or more of c("x","y") defining which scale(s) to navigate along (e.g. zoom in). |
trans.scales |
one or more of c("x","y") defining which scale(s) to transform (e.g. log). |
buttons |
a list of button definitions for the toolbar.
Normally this is a subset of the predefined plotAndPlayButtons .
Note that buttons to choose Lattice panels and pages are added automatically if relevant.
See the Details section if you want custom buttons. |
extra.buttons |
same as buttons , provided for convenient additions to the default set. |
labels |
a character vector of labels for data points, for use in identify . If missing, it will be guessed from the plot call. If identify.call is given, it is ignored. |
identify.call |
a call to be evaluated when the identify button is clicked. If missing, it will be constructed from the plot call. Generally this argument should not be needed. |
is.lattice |
whether the plot is a Lattice plot, or a traditional graphics plot. If the called function is in the lattice package it will be recognised automatically. |
eval.args.pattern |
a regular expression matching the argument values to evaluate in the plot call. See below. |
envir |
environment to use in evaluating the call arguments (see eval.args.pattern ) |
plotAndPlay
works best with Lattice plots. There is only basic support for traditional graphics plots.
Each element of buttons
is a named list passed as arguments to
function(label, icon.name=NULL, f, data=NULL, isToggle=F)
, with:
name
giving the plot identifier.gtkToggleToolButton
.
For example, one element of plotAndPlayButtons
is
zoomout=list("Zoom out", "gtk-zoom-out", f=.plotAndPlay_zoomout_event)
.
New callback functions should be adapted from the pre-defined ones.
If all arguments are evaluated (eval.args.pattern="."
) then the PlotAndPlay window will be independent of the R session and any changes to the original data.
If arguments are not evaluated until plot time (eval.args.pattern="$^"
) then less memory will be used to store the call, but the plot will depend on all the variables used as arguments remaining accessible (i.e. in the global environment). Also the plot will change along with the original data (and may cause confusion, e.g. labels
may be wrong).
If plotAndPlay
is called inside a function, any local variables need to be evaluated as they will be inaccessible to callback functions (so interaction will fail).
plotAndPlay
invisibly returns the value from the plot call
(which for lattice plots is a "trellis" object).
Felix Andrews felix@nfrac.org
## Not run: require(lattice) plotAndPlay(xyplot(Income ~ Population / Area | state.region, data=data.frame(state.x77))) ## same plot with one panel per page plotAndPlay(xyplot(Income ~ Population / Area | state.region, data=data.frame(state.x77), layout=c(0,1)), name="other") ## time series plot: navigate x-axis only, transform y-axis treering2 <- window(treering, 0, 1979) plotAndPlay(plot(treering2), nav.scales="x", trans.scales="y", labels=paste(time(treering2),"CE"), extra.buttons=plotAndPlayButtons['logscale']) # see what the current call is str(as.list(plotAndPlayGTK:::.StateEnv$call[["plot"]])) ## End(Not run)