[R] Interacting with graphics: image

Prof Brian D Ripley ripley at stats.ox.ac.uk
Wed Aug 1 11:11:07 CEST 2001


On Wed, 1 Aug 2001, Agustin Lobo wrote:

> After displaying a matrix x with image(x),
> is there any way to check the x values with the
> cursor? I've tried locator() and identify(), but does not seem
> to be the way.

It is the way.  For example, from ?image:

     data(volcano)
     x <- 10*(1:nrow(volcano))
     y <- 10*(1:ncol(volcano))
     image(x, y, volcano, col = terrain.colors(100), axes = FALSE)

     clicked <- locator()
     volcano[cbind(round(clicked$x/10), round(clicked$y/10))]

(You will need to do the mapping to coordinates in a problem-specific way,
and indeed this will depend on exactly hoe image was called.)

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list