switch from GUI axes to figure() and back

I want to plot my graph either in GUI axes or in a separate figure As Walter recommended ( http://www.mathworks.com/matlabcentral/answers/22208-show-figure) I could switch to figure() using
if PlotInFigure
handles.Fig1_axes=axes('Parent',figure(1));
end
plot(handles.Fig1_axes,x,y,'-b'),
Now I want to plot my graph in GUI axes during the next run of my code (with a different value of checkbox, for instance)
if ~PlotInFigure
???
end
plot(handles.Fig1_axes,x,y,'-b'),
How can I do it? Thanks!

 Accepted Answer

if PlotInFigure
handles.Fig1_axes = axes('Parent', figure(1));
plot_into = handles.Fig1_axes;
else
plot_into = TheHandleOfTheAxesInTheGUI;
end
plot(plot_into, x, y, '-b'),

4 Comments

Walter, the handle of the axes in the GUI (tag) is Fig1_axes.
Now I understood. I have to do
if PlotInFigure
f = axes('Parent', figure(1));
plot_into = f;
else
plot_into = handles.Fig1_axes
end
plot(plot_into, x, y, '-b'),
You can compact two lines as you do not need "f".
plot_into = axes('Parent', figure(1));
I have done it already) And everything works. Thanks, Walter!

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!