Thread Subject: Getting pointer position within axes

Subject: Getting pointer position within axes

From: Michelle

Date: 26 Feb, 2008 17:47:01

Message: 1 of 5

Hello,

Here is what I would like to do:

When my mouse rolls over a plot object in an axes, I want to
plot some text that identifies the object, directly next to
the object. I don't want to have to click on the object to
make this text display in the axes. I just want to roll
over the object.

I have the Image Processing Toolbox installed, and have
tried working with iptPointerManager to accomplish the
desired task. However, the iptPointerManager seems to
maintain only the pointer's current position in the figure,
and in pixels. I don't know how to translate the pointer
position (in pixels, with respect to the figure) to the
location of the plotted object (in data units, with respect
to the axes).

Can anyone suggest a solution?

Thank you,

Michelle Kline

Subject: Getting pointer position within axes

From: Ilya Rozenfeld

Date: 26 Feb, 2008 20:49:02

Message: 2 of 5

Check help for "WindowButtonMotionFcn" and "CurrentPoint".

In the callback for WindowButtonMotionFcn you can query
cursor position (in the figure coordinates) using
CurrentPoint property and if it is close enough to your
object then trigger some event.


"Michelle " <mkline@egi.utah.edu> wrote in message
<fq1jal$jg7$1@fred.mathworks.com>...
> Hello,
>
> Here is what I would like to do:
>
> When my mouse rolls over a plot object in an axes, I
want to
> plot some text that identifies the object, directly next
to
> the object. I don't want to have to click on the object
to
> make this text display in the axes. I just want to roll
> over the object.
>
> I have the Image Processing Toolbox installed, and have
> tried working with iptPointerManager to accomplish the
> desired task. However, the iptPointerManager seems to
> maintain only the pointer's current position in the
figure,
> and in pixels. I don't know how to translate the pointer
> position (in pixels, with respect to the figure) to the
> location of the plotted object (in data units, with
respect
> to the axes).
>
> Can anyone suggest a solution?
>
> Thank you,
>
> Michelle Kline

Subject: Getting pointer position within axes

From: Michelle

Date: 26 Feb, 2008 21:13:02

Message: 3 of 5

Thanks, Ilya.

I now see that I don't have to actually click with my mouse
to trigger the WindowButtonMotionFcn. A big problem still
remains, though. Now that I've got the cursor position, in
figure coordinates, how do I determine (programmatically)
what object my cursor is currently near? The objects are
points that I plotted in a graph axes using the plot
command. I have no way of telling what each point's
position is, in terms of figure units. (Or can I?) I only
know each point's position in my data units (for example age
vs. feet).

- Michelle

"Ilya Rozenfeld" <rozeni.nospam@alum.rpi.edu> wrote in
message <fq1tvu$mr3$1@fred.mathworks.com>...
> Check help for "WindowButtonMotionFcn" and "CurrentPoint".
>
> In the callback for WindowButtonMotionFcn you can query
> cursor position (in the figure coordinates) using
> CurrentPoint property and if it is close enough to your
> object then trigger some event.
>
>
> "Michelle " <mkline@egi.utah.edu> wrote in message
> <fq1jal$jg7$1@fred.mathworks.com>...
> > Hello,
> >
> > Here is what I would like to do:
> >
> > When my mouse rolls over a plot object in an axes, I
> want to
> > plot some text that identifies the object, directly next
> to
> > the object. I don't want to have to click on the object
> to
> > make this text display in the axes. I just want to roll
> > over the object.
> >
> > I have the Image Processing Toolbox installed, and have
> > tried working with iptPointerManager to accomplish the
> > desired task. However, the iptPointerManager seems to
> > maintain only the pointer's current position in the
> figure,
> > and in pixels. I don't know how to translate the pointer
> > position (in pixels, with respect to the figure) to the
> > location of the plotted object (in data units, with
> respect
> > to the axes).
> >
> > Can anyone suggest a solution?
> >
> > Thank you,
> >
> > Michelle Kline
>

Subject: Getting pointer position within axes

From: sourabh bora

Date: 16 Mar, 2008 21:49:03

Message: 4 of 5

Hi Michelle,
I am facing the same problem as you.. how to determine the
location of objects within the axes. I would be glad if you
let me know once you find the solution.
 A matlab program called freehanddraw.m can give you some
idea how to work with window mouse button.

  another approach you may try is using ginput.
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=7347&objectType=File
Thanks
Sourabh Bpra

"Michelle " <mkline@egi.utah.edu> wrote in message
<fq1vcu$f80$1@fred.mathworks.com>...
> Thanks, Ilya.
>
> I now see that I don't have to actually click with my mouse
> to trigger the WindowButtonMotionFcn. A big problem still
> remains, though. Now that I've got the cursor position, in
> figure coordinates, how do I determine (programmatically)
> what object my cursor is currently near? The objects are
> points that I plotted in a graph axes using the plot
> command. I have no way of telling what each point's
> position is, in terms of figure units. (Or can I?) I only
> know each point's position in my data units (for example age
> vs. feet).
>
> - Michelle
>

Subject: Getting pointer position within axes

From: Rikki

Date: 4 Jun, 2009 14:24:01

Message: 5 of 5

Look at this link: http://msenux.redwoods.edu/Math4Textbook/Programming/NestedFunctions.pdf

#7 at the end shows you exactly how to do this.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
plot units Michelle 26 Feb, 2008 16:15:18
iptpointermanager Michelle 26 Feb, 2008 12:50:11
pointer Michelle 26 Feb, 2008 12:50:11
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com