Last chance! 50% off unlimited learning
Sale ends in
playwith
Application Programming Interface.playPointInput(playState, prompt = "Click on the plot")
playLineInput(playState, prompt = "Click and drag to define a line")
playRectInput(playState, prompt = "Click and drag to define a rectangular region",
scales = c("x", "y"))
playState
object representing the plot, window and device."x"
and "y"
,
constraining the dimensions of the region to select.
E.g. if scales="x"
then a section along the x-axis is selected,
as might be appropriate for a time series.NULL
if the user cancelled (e.g. by right-clicking).
The return value is a list with:space
space
argument to playDo
.coords
space
.
A list with numeric vectors x
and y
.
For a rectangle or line, these are length 2 where the first element
refers to the start of the drag motion. For a point these are length 1.
If space
is "page"
, this is NULL
.dc
ndc
is.click
playPointInput
.modifiers
flag
representing which modifier keys were
pressed during the click (or at the end of a drag).
E.g. to test for Shift key:
if (foo$modifiers & GdkModifierType["shift-mask"])
.
See enums-and-flags
.playPointInput
is similar to locator
, but
returns native coordinates in whichever plot space was clicked on.
Device coordinates and normalised device coordinates are also available.
playRectInput
and playLineInput
allow the user to
interactively draw a rectangle or line.playSelectData
, playwith.API
if (interactive()) {
library(lattice)
playwith(xyplot(Sepal.Width ~ Petal.Width | Species, data = iris))
playPointInput(playDevCur())
playRectInput(playDevCur())
}
Run the code above in your browser using DataLab