MATLAB: I have 2 axes in a gui that the 2 graphs are plotted. how can i plot the 2 graphs in a new window and then save them

axesguiplot

i use the following code in a function:
axes(handles.axesrosediagram)
handles.alf=transpose(handles.table)
scatter(handles.alf,handles.final_table);
axes(handles.axes11)
rose(handles.final_table);

Best Answer

  • newfig = figure();
    newax1 = subplot(2, 1, 1, 'Parent', newfig);
    scatter(newax1, handles.alf,handles.final_table);
    newax2 = subplot(2, 1, 2, 'Parent', newfig);
    rose(newax2, handles.final_table);
    saveas(newfig, 'OutputFileNameHere.png', 'png') %save it as PNG
    delete(newfig)