MATLAB Answers

How can I save plot in my gui to file?

34 views (last 30 days)
JoE on 9 Jan 2013
My question is as simple as it looks like. I've tried many ways to do it, but it is still not doing, what I want. I have a gui, which contains axes, where my plot is displayed. And I need to save this plot to file (of whatever extension).
In forums there are a lot of solutions and some of them particulary worked. That means the figure wasn't complete (just a part of it has been saved in file) or in file has been saved something like printscreen of my gui.
Is there a simple solution for that? Thank you very much for any answers.


Show 2 older comments
JoE on 10 Jan 2013
I have just solved this problem. I just put command "figure()", and now the plot appears in separately window with save button and all tools I may need in future.
Thank you for your time.
Jan on 10 Jan 2013
Then please post the code you have tried and explain the occurring problems with details, e.g. if the result differs from your expectations or you get an error message.
JoE on 19 Feb 2013
function SaveAs_Callback(~, ~, ~)
global PlotData x y X n
PlotData = plot (x,y,'.','MarkerEdgeColor','k','MarkerSize',8);
hold on
set (gca,'XTick',0:0.1:1)
set (gca,'XTickLabel',{'0','0.1','0.2','0.3','0.4','0.5','0.6','0.7','0.8','0.9','1.0'})
xlabel ('phase')
ylabel ('intensity')
a = (0:0.001:1);
b = X(1,1);
for i = 1:n
b = b+X(i+1,1)*cos(2*pi*i*a)+X(i+n+1,1)*sin(2*pi*i*a);
PlotFit = plot (a,b);
hold off
set (PlotFit,'Color','k','LineWidth',2)
This is part of my code. It plots graph of two measured variables (x,y) and theoretical fit over this graph.
My goal was to save this picture using Save context menu. Idea was to open "Save as" dialog box. But unsuccessfull. So I tried this and put the keyword figure(). After clicking on this button picture is opened in new window with all of these edit functions, save buttons etc. Not what I want, but one step closer to that. :)
Thanks for any advices.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 9 Jan 2013
The most popular solution for saving figures is mentioned in The FAQ


Sign in to comment.

Community Treasure Hunt

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

Start Hunting!