MATLAB: How to save a gui plot in a new file

guiimage fileplotsavesaveas

Hello everyone,
I need your help.
I'm making a GUI with several push buttons and axes. By clicking in a push button, appears a graph in the axes.
What I want to do is, by clicking in other push button, it saves the image in a new image file.
This is what I have: ————————————————————————————————————– function [ output_args ] = gera_imagem (grafico_i)
[ficheiro_nome3, directoria_nome3] = uiputfile('*.jpeg;*.tif;*.png;*.gif', 'Guardar a imagem:'); nome3 = fullfile(directoria_nome3,ficheiro_nome3);
saveas(grafico_i,nome3);
end —————————————————————————————————————
grafico_i is the plot that appears on GUI and that's what I want to save in the file named nome3..
What that saveas do is to save a bit of the GUI menu, not the graph…
How do I copy the graph that's created in the GUI to the new image file?
Can you help please?
Thanks a lot, Mara

Best Answer

Our daily "how do I save a figure?" question. The usual answer is to read the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_save_my_figure.2C_axes.2C_or_image.3F_I.27m_having_trouble_with_the_built_in_MATLAB_functions. which basically recommends to try export_fig (the most downloaded of all File Exchange submissions, for good reason). If export_fig doesn't work then some people have had success with changing the renderering method (painters, z-buffer, or whatever) but I've never had to resort to that.