Greetings Friends: I am trying to find a widget or some other method to let me interrogate a 2-D image using the mouse. I have a data.frame that I can visualize using image() in R. I would like to point to a pixel and have its coordinates displayed. I've read Peter Dalgaard's primer on R-Tcl/Tk, R-News, 1(3):27-31, and his update R-News2(3):25-27, but am still struggling. Can anyone suggest a method for interactively interrogating of a 2-D image? Many thanks. Charles Annis, P.E. Charles.Annis at StatisticalEngineering.com phone: 561-352-9699 eFax: 503-217-4849 http://www.StatisticalEngineering.com
interactive 2-D plot interrogation
3 messages · Charles Annis, P.E., Dirk Eddelbuettel, Paul Murrell
On Sun, Feb 01, 2004 at 01:53:14PM -0500, Charles Annis, P.E. wrote:
Greetings Friends: I am trying to find a widget or some other method to let me interrogate a 2-D image using the mouse. I have a data.frame that I can visualize using image() in R. I would like to point to a pixel and have its coordinates displayed. I've read Peter Dalgaard's primer on R-Tcl/Tk, R-News, 1(3):27-31, and his update R-News2(3):25-27, but am still struggling. Can anyone suggest a method for interactively interrogating of a 2-D image?
Look at the InteractiveTkrPlot example on James Wettenhall's site: http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/InteractiveTkrPlot.html His example is over discrete set of points, which you can adapt to find the location with respect to curves or lines (which I did at work, where I can't get to right now). The key is that the 'widget' you bind to an event (like left-Mouse in his example) get (x,y) pixel coordinates from the system which given appropriate information from par() can be translated into your data coordinates in just a few steps. James' site is a treasure chest for R and tcltk. Highly recommended. Hope this helps, Dirk
The relationship between the computed price and reality is as yet unknown.
-- From the pac(8) manual page
Hi Depending on how you want the coordinates displayed, the locator() function may help you, or perhaps a simple function written around locator() to process its result into something more meaningful for your siutation. Paul
Dirk Eddelbuettel wrote:
On Sun, Feb 01, 2004 at 01:53:14PM -0500, Charles Annis, P.E. wrote:
Greetings Friends: I am trying to find a widget or some other method to let me interrogate a 2-D image using the mouse. I have a data.frame that I can visualize using image() in R. I would like to point to a pixel and have its coordinates displayed. I've read Peter Dalgaard's primer on R-Tcl/Tk, R-News, 1(3):27-31, and his update R-News2(3):25-27, but am still struggling. Can anyone suggest a method for interactively interrogating of a 2-D image?
Look at the InteractiveTkrPlot example on James Wettenhall's site: http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/InteractiveTkrPlot.html His example is over discrete set of points, which you can adapt to find the location with respect to curves or lines (which I did at work, where I can't get to right now). The key is that the 'widget' you bind to an event (like left-Mouse in his example) get (x,y) pixel coordinates from the system which given appropriate information from par() can be translated into your data coordinates in just a few steps. James' site is a treasure chest for R and tcltk. Highly recommended. Hope this helps, Dirk
Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/