Skip to content

grid.locator

3 messages · Gabor Grothendieck, Paul Murrell

#
If I do:

library(lattice)
x <- 1:10
xyplot(x ~ x)
grid.locator()

and click on 2,2 say the I get this:
$x
[1] 201native

$y
[1] 476native

How do I get the user coordinates of the graph?

(If I did not use lattice/grid I could have just done:

plot(x ~ x)
locator()

and it would have worked as expected.)
#
Hi
Gabor Grothendieck wrote:
After the lattice plot, you are back at the top-level grid viewport.
grid.locator() by default gives you the click in "native" coordinates. 
The "native" coordinates for the top-level viewport depend on the 
device;  on-screen it is pixel-based.
Look up the lattice function trellis.focus().

Paul

  
    
#
Thanks.  Following the example there worked.

I suggest adding trellis.focus to the See Also in ?grid.locator
On 9/25/05, Paul Murrell <p.murrell at auckland.ac.nz> wrote: