Save figure with all subplots
显示 更早的评论
I generated a lot of figures with subplots. I want to save them and don't want to display them.
I realized only the last subplot is saved. Is there anyway I can save all subplots in a figure.
The following is an example code.
t=linspace(1,10,20);
y=2*t;
for i=1:3
f=figure('visible','off');
subplot(1,3,i)
p=plot(t,y);
saveas(f,'test','jpg')
end
1 个评论
Trang Doan
2021-4-19
移动:Adam Danz
2024-10-7
how to save 1 figure of the subplots
回答(1 个)
Walter Roberson
2019-10-9
Construct new file names each iteration.
saveas(f, sprintf('test%d.jpg', i))
4 个评论
Walter Roberson
2019-10-9
That would overwrite test.jpg each iteration.
Sharon
2019-10-9
Adam Danz
2024-10-7
exportgraphics(fig, filename)
类别
在 帮助中心 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!