how to do a subplot loop?
3 ビュー (過去 30 日間)
古いコメントを表示
Hi, I'm trying to subplot whithin a for loop. I'm asking matlab tu plot me three contourf called nzero_mean1, nzro_mean2, nzro_mean3 in a single subplot and each countourf has a title. But I don't know how to make those trhee contourf at one subplot in a forloop. I need help. I'm currently doing it like this:
figure
subplot(1,3,1)
contourf(nzro_frec1)
set(gca,'XTickLabel',vec)
set(gca,'YTickLabel',vec)
title('Especie 1')
colorbar('southoutside')
subplot(1,3,2)
contourf(nzro_frec2)
set(gca,'XTickLabel',vec)
set(gca,'YTickLabel',vec)
title('Especie 2')
colorbar('southoutside')
subplot (1,3,3)
contourf(nzro_frec3)
set(gca,'XTickLabel',vec)
set(gca,'YTickLabel',vec)
title('Especie 3')
colorbar('southoutside')
[ax1,h1]=suplabel('Delta m3');
[ax2,h2]=suplabel('Delta m2','y');
[ax3,h3]=suplabel('Frecuencia de sobrevivencia. Alpha = 0. p=10. Respuesta Sigmoide (s=2)' ,'t');
set(h3,'FontSize',20)
set(h1,'FontSize',14)
set(h2,'FontSize',14)
orient portrait
print('-dps','suplabel_test')
%unix('convert suplabel_test.ps suplabel_test.jpg');
0 件のコメント
採用された回答
Image Analyst
2018 年 9 月 5 日
It wouldn't be worth it. You'd have to have if blocks in the loop to handle cases that should be different on every loop but don't depend on the loop iterator. Sure you could do
for k = 1 : 3
subplot(1, 3, k);
% code
caption = sprintf('Especie %d', k);
title(caption);
end
but the contourf, etc. are not a function of k so you'd have to say
if k == 1
contourf(nzro_frec1)
colorbar('southoutside')
elseif k == 2
contourf(nzro_frec2)
colorbar('southoutside')
etc. that essentially the looping is not gaining you anything.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Subplots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!