Save axes plot as '.fig' in a GUI

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!

 Respuesta aceptada

Jan
Jan el 9 de Sept. de 2013

4 votos

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 comentario

Manuel
Manuel el 10 de Sept. de 2013
Editada: Manuel el 10 de Sept. de 2013
Everything works! Thanks!

Iniciar sesión para comentar.

Más respuestas (1)

Sean de Wolski
Sean de Wolski el 9 de Sept. de 2013

1 voto

You can't directly save just the axes. Instead, use export_fig with the cropping option

5 comentarios

Image Analyst
Image Analyst el 9 de Sept. de 2013
I agree. I think it would be a better idea to save the axes as a .PNG file (a widely used lossless compression format) rather than a .fig file. Then the picture will be available to any program, not just MATLAB.
Manuel
Manuel el 10 de Sept. de 2013
Actually Im already using 'export_fig' to save the picture in .png format, but I would like to save also in .fig in order to make future changes on labels, legends... and 'export_fig' has not this option. Any idea how to make it?
Jan
Jan el 10 de Sept. de 2013
What about using hgsave directly.
loghman
loghman el 4 de Feb. de 2018
copyobj doesn't work for axes with multiple coordinated system. what should i do?
loghman
loghman el 4 de Feb. de 2018
copyobj doesn't work for axes with multiple coordinated system. what should i do?

Iniciar sesión para comentar.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 9 de Sept. de 2013

Comentada:

el 4 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by