Learn R Programming

playwith (version 0.9-11)

whichSpace: Convert device coordinates to plot space

Description

Part of the playwith Application Programming Interface.

Usage

whichSpace(playState, x.device, y.device)

deviceCoordsToSpace(playState, x.device, y.device, space = "plot")

Arguments

playState
a playState object representing the plot, window and device.
x.device
x coordinate in pixels on the graphics device.
y.device
y coordinate in pixels on the graphics device.
space
character, the plot space for which to get or set limits. See the space argument to playDo.

Value

  • whichSpace returns the space value referring to the plot space in which the point (x.device, y.device) lies. See the space argument to playDo. If the coordinate is not inside any plot spaces, "page" is returned. deviceCoordsToSpace converts the given device coordinates to native coordinates in the specified space. It returns a list with numeric components x and y, and a logical inside, whether the given point lies inside the space boundaries.

See Also

playwith.API

Examples

Run this code
if (interactive()) {

library(lattice)
packs <- paste("packet", rep(1:3, each=4))
playwith(xyplot(1:12 ~ 1:12 | packs))
playState <- playDevCur()
dc <- playPointInput(playState)$dc
whichSpace(playState, dc$x, dc$y)
deviceCoordsToSpace(playState, dc$x, dc$y, space="packet 1")
deviceCoordsToSpace(playState, dc$x, dc$y, space="packet 2")

}

Run the code above in your browser using DataLab