Avoid saving multiple figures when trying to save a figure prompted by a GUI as .fig?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Gil Zimmerman
il 23 Ott 2018
Risposto: Gil Zimmerman
il 15 Giu 2021
I have a complex GUI that is used to generate multiple plots and figures. Let's call the main GUI figure handles.figureMain and the figure generated by a callback in the main GUI, handles.figurePlot.
In figurePlot, selecting File>Save As... *.fig creates a .fig file that includes both figures: figureMain and figurePlot.
How can I make sure only figurePlot is saved in the .fig file?
Things I have tried that haven't worked:
- Turning off handle visibility to figureMain
handles.figureMain.HandleVisibility = 'Off'
- Turning off graphical visibility to figureMain before saving
handles.figureMain.Visible = 'Off'
- Modifying the File>Save As... menu item in figurePlot to a modified callback function that invokes savefig instead of saveas .
hMenuFile = findall(handles.figurePlot,'type','uimenu','tag','figMenuFile');
hSaveFigure = findall(handles.figurePlot,'type','uimenu','tag','figMenuFileSaveAs');
set(hMenuFile,'Callback','filemenufcn_custom FilePost')
set(hSaveFigure,'Callback','filemenufcn_custom(gcf,''FileSaveAs'')')
(I have also tried gcbo instead of gcf .) Then in filemenufcn_custom > localSaveExportHelper :
if strcmp(types{typevalue,4},'fig') && ~fromExport
savefig(hfig, filename, 'compact')
% saveas(hfig,filename); % original/replaced code
else
...
- Setting the InSaveFig property of figureMain to 'Off'
set(handles.figureMain,'InSaveFig','off')
- I have also checked children and parents, and tracked down the figure handle all the way until it is written using FF.write() in savefig and I cannot find any reason why handles.figureMain should be included in saving handles.figurePlot as a .fig.
The only thing that works (partially) is actually closing figureMain before saving figurePlot but this isn't feasible for my purposes.
Saving the additional figure is quite costly in terms of time and memory so a solution would be appreciated.
Thanks.
6 Commenti
Christoph Neumann
il 15 Giu 2021
This malfunction appears (in my application) only together with "copyobj", where an axes from the GUI main window is copied to the separate figure. In this case, "saveas" or "savefig", addressing the separate figure, is saving both the GUI main window and the separate figure.
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Printing and Saving in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!