How do I make my GUI plot inside of a new figure in MATLAB rather than into an axes within the GUI figure?

How do I make my GUI plot inside of a new figure in MATLAB rather than into an axes within the GUI figure?
Actually I am able to make a plot into the GUI axes which I have made but I want to save that graph.It is only possible when it is in other new figure.Could you please help me regarding this?
When I used this command- set(hObject,'toolbar','figure'); guidata(hObject, handles);
it will save the whole GUI figure instead of only graph.
Could you please suggest any way so that I can save only my graph instead of whole gui figure?
Thanks
Arif

 Accepted Answer

In your code, before running the plot, create a new figure, like
f=figure;
plot(magic(10));
saveas(f,...);

3 Comments

Thank you very much.It is working but after plotting the new figure it also give an error.Could you please solve it?
My code is-
f=figure;
plot(magic(10));
saveas(f,logo.fig);
The error is-
??? Error while evaluating uicontrol Callback
??? Undefined variable "logo" or class "logo.fig".
Error in ==> GUI>pushbutton1_Callback at 83
saveas(f,logo.fig);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> GUI at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)GUI('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
saveas(f,'logo','fig'). Type help saveas to see the syntax of saveas()

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!