
playwith
Application Programming Interface.playDo(playState, expr, space = "plot", clip.off = FALSE)
playState
object representing the plot, window and device.expr
.
This can be "plot", "page", or for lattice plots "packet N" (where N is a packet number),
or for grid plots the name of a viewport passed to the viewport
argumentclip
argument to viewport
.expr
.gridBase
package. That means expr
can always use Grid drawing operations.
The default space="plot"
will work for base graphics, grid graphics and for single-panel lattice plots.
It will also work for multi-panel lattice plots when one panel is in focus (see trellis.focus
).
Using space="page"
will apply to the whole device space (root viewport).
Other functions such as playSelectData
and playPointInput
return values that can be used directly for the space
argument.playwith.API
,
playSelectData
, playPointInput
,
whichSpace
if (interactive()) {
library(lattice)
library(grid)
packs <- paste("packet", rep(1:4, each=4))
playwith(xyplot(1:16 ~ 1:16 | packs))
myGp <- gpar(fill="red", col="black", alpha=0.5)
## draw in a specific packet
playDo(playDevCur(), grid.circle(gp=myGp), space="packet 2")
## draw in default space="plot" after focussing on one panel
trellis.focus("panel", 1, 1)
packet.number() # 1, same as space="packet 1"
playDo(playDevCur(), grid.circle(gp=myGp))
trellis.unfocus()
## space="plot" does not work in a multi-panel plot
## unless one panel is in focus
try(playDo(playDevCur(), grid.circle(gp=myGp)))
## draw on the whole page
playDo(playDevCur(), grid.circle(gp=myGp), space="page")
}
Run the code above in your browser using DataLab