Save axes plot as '.fig' in a GUI

29 vues (au cours des 30 derniers jours)
Manuel
Manuel le 9 Sep 2013
Commenté : loghman le 4 Fév 2018
I have a GUI in which one an axes is located with a plot and I would like to save this axes as '.fig' file. I have tried with :
[FileName,PathName] = uiputfile;
saveDataName = fullfile(PathName,FileName);
axes(handles.Graph1_axes);
saveas(gca, saveDataName, 'fig');
But this commands save all the GUI interface as '.fig'. Any help will be welcome.
Thanks in advance!

Réponse acceptée

Jan
Jan le 9 Sep 2013
The FIG format contains the complete figure (as the name says already). If you want to save a single axes only and definitely want the FIG format, you can copy the axes to a new figure:
Fig1 = figure;
AxesH = axes;
plot(1:10, rand(10,10));
Fig2 = figure;
copyobj(AxesH, Fig2);
hgsave(Fig2, 'myFigure.fig');
  1 commentaire
Manuel
Manuel le 10 Sep 2013
Modifié(e) : Manuel le 10 Sep 2013
Everything works! Thanks!

Connectez-vous pour commenter.

Plus de réponses (1)

Sean de Wolski
Sean de Wolski le 9 Sep 2013
You can't directly save just the axes. Instead, use export_fig with the cropping option
  5 commentaires
loghman
loghman le 4 Fév 2018
copyobj doesn't work for axes with multiple coordinated system. what should i do?
loghman
loghman le 4 Fév 2018
copyobj doesn't work for axes with multiple coordinated system. what should i do?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Printing and Saving dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by