How can I make the layout in the attached image with tiledlayout

조회 수: 3 (최근 30일)
AP
AP 2024년 5월 19일
편집: Matt J 2024년 5월 20일
I am able to get plot 1 and plot 2 in but not 3, 4 and 5. I can also get 3, 4 and 5 in without plot 1 and 2 but that is not what I want, per the attached image.

채택된 답변

Star Strider
Star Strider 2024년 5월 19일
편집: Star Strider 2024년 5월 19일
It took a few experiments to get this to work.
Try this —
x = 0:0.1:31;
y = sin((1:5).'*x*2*pi/32);
figure
tiledlayout(4,4)
nexttile([1 2])
plot(x,y(1,:))
grid
title('Plot 1')
nexttile([2 2])
plot(x,y(3,:))
grid
title('Plot 3')
nexttile([1 2])
plot(x, y(2,:))
grid
title('Plot 2')
nexttile([2 2])
plot(x, y(4,:))
grid
title('Plot 4')
nexttile([2 2])
plot(x, y(5,:))
grid
title('Plot 5')
EDIT — Corrected typographical errors.
.

추가 답변 (2개)

Matt J
Matt J 2024년 5월 19일
편집: Matt J 2024년 5월 20일
If you download nestedLayouts,
then you can do,
x = 0:0.1:31;
y = sin((1:5).'*x*2*pi/32);
[ax,t]=nestedLayouts([2,2],[2,1]);
delete(ax([4,6,8]));
ax=ax([1,2,3,5,7]);
for k=1:numel(ax)
plot(ax(k), x,y(k,:));
title(ax(k), "Plot "+k);
if k>2, ax(k).Layout.TileSpan=[2,1]; end
end
for i=1:numel(t), ylabel(t(i),"YLabel "+i); end

Image Analyst
Image Analyst 2024년 5월 20일
If you understand how subplots work, it's easy. The bottom and right plots just use a 2,2 layout while the upper left two use a 4,2 layout:
subplot(4, 2, 1);
title('Plot 1');
subplot(4, 2, 3);
title('Plot 2');
subplot(2, 2, 2);
title('Plot 3');
subplot(2, 2, 3);
title('Plot 4');
subplot(2, 2, 4);
title('Plot 5');
Many people don't realize it but whatever layout you use for your first subplot(s) does not need to be used for ALL subplots on the figure, so you can switch from 4 rows, 2 columns to 2 rows and 2 columns like I did above.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by