Save all the plots
790 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Each time I run my code it produces 100 figures. So, I have to waste my time and save each one of them. Is there a command that can do that work for me by saving all the figures at once?
1 Commento
Hira
il 27 Set 2022
m=1;
title("S31 Plot Measurement Number ("+m+")")
xlabel('Delay')
ylabel('Mag(S31)')
saveas(gcf,"S31_plot_"+name+"_Measurement_No_"+m+".fig")
close(gcf)
m=m+1;
Risposta accettata
Jan
il 11 Mar 2015
No, there is no such command. But it is easy to write one:
FolderName = tempdir; % Your destination folder
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
FigHandle = FigList(iFig);
FigName = get(FigHandle, 'Name');
savefig(FigHandle, fullfile(FolderName, FigName, '.fig'));
end
Adjust the FigName to your needs.
5 Commenti
Lars Abrahamsson
il 18 Mag 2020
I noticed one "problem" when saving all figures into one file.
When loading them back with "openfig" the numbers/order of the figures becomes revered.
Why is that? Can anything be done to counteract that?
Brandon Laflen
il 19 Mag 2020
If they load backwards, I'm guessing findobj is LIFO. Maybe try
savefig(FigList(end:-1:1),filename)
instead?
Più risposte (3)
Luke Shaw
il 30 Nov 2018
Modificato: Luke Shaw
il 30 Nov 2018
Missed a make current step: set(0, 'CurrentFigure', figureHandle)
FolderName = tempdir; % Your destination folder
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
FigHandle = FigList(iFig);
FigName = num2str(get(FigHandle, 'Number'));
set(0, 'CurrentFigure', FigHandle);
savefig(fullfile(FolderName, [FigName '.fig']));
end
4 Commenti
manvir kaur
il 6 Giu 2022
i have same issue, this code works perfectly but i want to save figures in png format. So how to do that. Thanks
Nabil Mederbel
il 11 Giu 2022
Hi guys,
I tried to save figures with '.eps' format ...didnt work.
any idea ? thx
Tanveer
il 18 Set 2022
FolderName = 'xx'; % Your destination folder
FigList = findobj(allchild(0), 'flat', 'Type', 'figure');
for iFig = 1:length(FigList)
FigHandle = FigList(iFig);
FigName = ['Fig' num2str(iFig)];
savefig(FigHandle, fullfile(FolderName, [FigName '.fig']));
saveas(FigHandle, fullfile(FolderName, [FigName '.png']));
% saveas(FigHandle,filename,formattype)
end
0 Commenti
Mehri Mehrnia
il 3 Ago 2022
Based on the answers, it means there is no 1 line of code which can save all open plots?
1 Commento
Hira
il 27 Set 2022
m=1;
title("S31 Plot Measurement Number ("+m+")")
xlabel('Delay')
ylabel('Mag(S31)')
saveas(gcf,"S31_plot_"+name+"_Measurement_No_"+m+".fig")
close(gcf)
m=m+1;
Vedere anche
Categorie
Scopri di più su Historical Contests 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!