playPointInput

0th

Percentile

Get point, line or rect input from playwith user

Part of the playwith Application Programming Interface.

Keywords
programming
Usage
playPointInput(playState = playDevCur(), prompt) playLineInput(playState = playDevCur(), prompt, scales = "dynamic") playRectInput(playState = playDevCur(), prompt, scales = "dynamic")
Arguments
playState
a playState object representing the plot, window and device.
prompt
text to display in the prompt.
scales
the default allows the user to hold Shift while dragging, to constrain the selection to x or y scales. Otherwise this should be one or more of "x" and "y", specifying which axes to select along.
Details

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.

Value

All these functions return NULL if the user cancelled (e.g. by right-clicking). Otherwise a list with:
space
character, specifies the plot space in which the user clicked or dragged. See the space argument to playDo.
coords
native coordinates of the point or shape in 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
device coordinates of the point or shape (pixels).
ndc
normalised device coordinates of the point or shape.
is.click
logical, whether it was a click (so probably should not be treated as a rectangle or line). This is not returned by playPointInput.
modifiers
a 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.

See Also

playSelectData, playwith.API

Aliases
  • playPointInput
  • playLineInput
  • playRectInput
Examples
if (interactive()) {

library(lattice)
playwith(xyplot(Sepal.Width ~ Petal.Width | Species, data = iris))
playPointInput()
playRectInput()

}
Documentation reproduced from package playwith, version 0.9-54, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.