How can I save plot in my gui to file?

Hi.
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.

5 commentaires

Jan
Jan le 9 Jan 2013
Please post what you have tried so far. The answer depends on the format you want to save the file in, e.g. EMF, PDF, FIG or PNG, so please specify this.
JoE
JoE le 10 Jan 2013
Especialy I need jpg and eps in color and greyscale as well. I have tried "hgsave", "saveas", "print" and more commands, but probably I'm doing something wrong, when it's not working correctly.
I can attached a printscreen of my gui, but I have no idea how. Thanks for help.
JoE
JoE le 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
Jan le 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.
function SaveAs_Callback(~, ~, ~)
global PlotData x y X n
figure();
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);
end
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.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 9 Jan 2013

0 votes

The most popular solution for saving figures is mentioned in The FAQ

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Question posée :

JoE
le 9 Jan 2013

Community Treasure Hunt

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

Start Hunting!

Translated by