Plotting on axes in a GUI after running the GUI's callback from a different script
2 views (last 30 days)
I have created a GUI called testGUI to demonstrate my issue. It has two axes (axes1, axes2) and a pushbutton. The pushbutton plots one set of data in each set of axes. The callback for the pushbutton is :
function plot_button_Callback(hObject, eventdata, handles)
This works fine when I use the mouse to click the pushbutton. However, I would like to run the GUI from another script.
fig_handle = testGUI;
handles = guidata(fig_handle);
Running the axes(handles.axes1) activates the testGUI figure but then opens a new figure and set of axes, plotting the data on that figure instead. Regardless of how I try to make the GUI figure current, if I run the plot_button_Callback from another script, it will open a new window. I can't find any differences in the figure properties. If I press the pushbutton with the mouse after opening the GUI from the separate script, everything plots as expected.
Any insight would be appreciated!
Matthew Eicholtz on 27 Sep 2016
Why do you want to run the callback from a script instead of using the pushbutton?
This line of code is actually calling the testGUI function, not just the callback, which is why a new testGUI figure is being opened.