From: Thomas Dickinson on
Hello,

I'm making a GUI that creates a plot in a separate figure (i.e just makes a plot on its own in a new figure).

I want to make it so that a button in the GUI figure, when pressed, will allow the user to do a ginput on the plot in the other figure.

Whenever I try to do a ginput, it just wants to ginput from the GUI window, and not the window in which the plot is located.

Is there a way to pass the handle of the new plot back to the GUI so that it knows where I'm trying to ginput?

Thanks very much!
From: Nicky on
From what I understand about ginput is that it takes it's points from the current axis. I haven't used it within a GUI so I don't know if the handles start to get messed up but it seems like if you call the ginput function after you create your new figure it will associate with that figure rather than the GUI.

"Thomas Dickinson" <geoffrey.seaborn(a)gmail.com> wrote in message <hp0cjp$hni$1(a)fred.mathworks.com>...
> Hello,
>
> I'm making a GUI that creates a plot in a separate figure (i.e just makes a plot on its own in a new figure).
>
> I want to make it so that a button in the GUI figure, when pressed, will allow the user to do a ginput on the plot in the other figure.
>
> Whenever I try to do a ginput, it just wants to ginput from the GUI window, and not the window in which the plot is located.
>
> Is there a way to pass the handle of the new plot back to the GUI so that it knows where I'm trying to ginput?
>
> Thanks very much!
From: Matthew Whitaker on
"Thomas Dickinson" <geoffrey.seaborn(a)gmail.com> wrote in message <hp0cjp$hni$1(a)fred.mathworks.com>...
> Hello,
>
> I'm making a GUI that creates a plot in a separate figure (i.e just makes a plot on its own in a new figure).
>
> I want to make it so that a button in the GUI figure, when pressed, will allow the user to do a ginput on the plot in the other figure.
>
> Whenever I try to do a ginput, it just wants to ginput from the GUI window, and not the window in which the plot is located.
>
> Is there a way to pass the handle of the new plot back to the GUI so that it knows where I'm trying to ginput?
>
> Thanks very much!
You should be able to do this by setting the current axes when clicking the button then starting ginput

For example:
function ginputOnDifferentFigureExample
guiFigure = figure('Units','pixels',...
'Position',[400,400,200,200]);
uicontrol('Parent',guiFigure,...
'Units','normalized',...
'Position',[0.3,0.3,0.4,0.4],...
'String','Start Input',...
'Callback',@input_Callback);

plotFigure = figure('Units','pixels',...
'Position',[620,400,400,400]);

axHdl = axes('Parent',plotFigure);

function input_Callback(varargin)
set(0,'CurrentFigure',plotFigure);
set(plotFigure,'CurrentAxes',axHdl);

[X,Y] = ginput;

plot(axHdl,X,Y);
end %inputCallback

end %ginputOnDifferentFigureExample

Hope this helps
Matt W
From: Thomas Dickinson on
Hello,

Thanks very much for your replies.

This works - I'm getting co-ordinates from the right axes.

However, there's one problem - I can't see the crosshairs or the mouse until ginput is done. I think they are behind the plot or something - I can see them when I mouse over the legend, but that's it (they show up when my mouse is inside the legend).

If you have any idea as to why this is happening, I would again appreciate your help.

Thanks