MATLAB: Save axes plot as ‘.fig’ in a GUI

axesfigguisaveas

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!

Best Answer

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');
Related Question