Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using ginput on an axes in a GUI?

214 views
Skip to first unread message

Clive

unread,
Sep 14, 2010, 12:24:08 PM9/14/10
to
Hi,
I have a GUI that contains a set of axes. I need to use ginput so a user can click on any point on the axes and obtain data from that point using the inpolygon function.

However, when the ginput function is called in the GUI script, the ginput crosshair isnt confined to the axes but the entire GUI figure. I have tried several methods to set the handles to the axes, for example:
[xp yp] = ginput(handles.axes, 1)
but nothing has worked.

Is there a way to confine ginput to the axes on the GUI only?

Thanks,
Clive

Sean

unread,
Sep 14, 2010, 12:45:22 PM9/14/10
to
"Clive " <cgro...@uni.sydney.edu.au> wrote in message <i6o7j8$qnn$1...@fred.mathworks.com>...

There is not to my knowledge. What you can do is find the bounds of your axes and, if the user selects outside these bounds, make them select again.

someone

unread,
Sep 14, 2010, 1:17:07 PM9/14/10
to
"Sean " <sean.d...@nospamplease.umit.maine.edu> wrote in message <i6o8r2$jto$1...@fred.mathworks.com>...

Or perhaps in your script, instead of calling ginput directly, you can call the ginput function using the axes ButtonDownFcn property. Since:

ButtonDownFcn is a callback that executes whenever you press a mouse button while the pointer is within the axes, but not over another graphics object parented to the axes.

Naresh Pai

unread,
Sep 14, 2010, 1:30:25 PM9/14/10
to
"Clive " <cgro...@uni.sydney.edu.au> wrote in message <i6o7j8$qnn$1...@fred.mathworks.com>...

Clive,

Try exploring the impixel function to do this instead of ginput.

Naresh

Divakar Roy

unread,
Nov 12, 2012, 11:53:17 PM11/12/12
to
I have just uploaded to file-exchange, codes that are supposed to solve the original problem. Here's the link - http://www.mathworks.com/matlabcentral/fileexchange/38997 . Basically it uses BUTTONDOWNFCN, alongwith uipanel. Would appreciate to know if the codes are any help to people still interested in the problem.

"Clive" wrote in message <i6o7j8$qnn$1...@fred.mathworks.com>...

Pedro Teodoro

unread,
Jan 12, 2013, 5:37:08 AM1/12/13
to
Try this.

It does exactly what you want. This function works as ginput but it is adapted to be used in GUIs.

http://www.mathworks.com/matlabcentral/fileexchange/39799
0 new messages