Save figure with all subplots

31 ビュー (過去 30 日間)
Sharon
Sharon 2019 年 10 月 9 日
コメント済み: Adam Danz 2024 年 10 月 7 日
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
Trang Doan 2021 年 4 月 19 日
移動済み: Adam Danz 2024 年 10 月 7 日
how to save 1 figure of the subplots

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 10 月 9 日
Construct new file names each iteration.
saveas(f, sprintf('test%d.jpg', i))
  4 件のコメント
Sharon
Sharon 2019 年 10 月 9 日
You are right. I should put saveas outside the loop.
Adam Danz
Adam Danz 2024 年 10 月 7 日
I'd also like to point readers in the direction of exportgraphics instead of saveas.
exportgraphics(fig, filename)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by