フィルターのクリア

Need help in MATLAB tiled layouts (nested)

44 ビュー (過去 30 日間)
Nooruddin Shaik
Nooruddin Shaik 2024 年 5 月 14 日
コメント済み: Voss 2024 年 5 月 14 日
I'm currently engaged in plotting figures within MATLAB and I'm aiming to create a figure with tiled layouts. I've managed to plot using tiled layout but in one of my use cases, I need to plot a tiled layout within another tiled layout, something like nested tiled layouts.
t=tiledlayout(2,2);
[X,Y,Z] = peaks(20);
% Tile 1
t1= nexttile(t);
t1=tiledlayout(1,2);
nexttile(t1)
surf(X,Y,Z)
nexttile(t1)
surf(X,Y,Z)
% Tile 2
nexttile(t)
contour(X,Y,Z)
% Tile 3
nexttile(t)
imagesc(Z)
% Tile 4
nexttile(t)
plot3(X,Y,Z)
I have gone through documentation and tried the above code but not working
Any insights or guidance would be greatly appreciated!
  1 件のコメント
Pavan Sahith
Pavan Sahith 2024 年 5 月 14 日
you can consider referring to this question

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

採用された回答

Voss
Voss 2024 年 5 月 14 日
Something like this?
t=tiledlayout(2,2);
[X,Y,Z] = peaks(20);
% Tile 1
t1=tiledlayout(t,1,2);
nexttile(t1)
surf(X,Y,Z)
nexttile(t1)
surf(X,Y,Z)
% Tile 2
nexttile(t)
contour(X,Y,Z)
% Tile 3
nexttile(t)
imagesc(Z)
% Tile 4
nexttile(t)
plot3(X,Y,Z)
  2 件のコメント
Nooruddin Shaik
Nooruddin Shaik 2024 年 5 月 14 日
yes , this is what I want for the sample code posted ,but I need to get a clear idea of arranging nested tiled layouts , I have to work on more layers ,I need to learn using the arguments of tiledlayout , like parent as mentioned in the documentation and many more
I think the documentation should be more clearly written.
t1=tiledlayout(t,1,2);
t is the parent in this line of code??
Voss
Voss 2024 年 5 月 14 日
Yes
t1=tiledlayout(t,1,2);
creates a tiledlayout t1 of size 1x2 in the 2x2 tiledlayout t. t is the parent of t1.
Here is another example, with more layers of nesting:
[X,Y,Z] = peaks(20);
figure
t = tiledlayout(2,2);
% Tile 1
t1 = tiledlayout(t,1,2);
t1.Layout.Tile = 1;
nexttile(t1);
surf(X,Y,Z)
t12 = tiledlayout(t1,2,1);
t12.Layout.Tile = 2;
nexttile(t12);
surf(X,Y,Z)
nexttile(t12);
plot3(X,Y,Z)
% Tile 2
t2 = tiledlayout(t,3,1);
t2.Layout.Tile = 2;
nexttile(t2)
contour(X,Y,Z)
nexttile(t2)
contourf(X,Y,Z)
nexttile(t2)
plot3(X,Y,Z)
% Tile 3
t3 = tiledlayout(t,1,3);
t3.Layout.Tile = 3;
nexttile(t3)
imagesc(X)
nexttile(t3)
imagesc(Y)
nexttile(t3)
imagesc(Z)
% Tile 4
nexttile(t)
plot3(X,Y,Z)

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

その他の回答 (1 件)

Matt J
Matt J 2024 年 5 月 14 日
編集済み: Matt J 2024 年 5 月 14 日
If you download nestedLayouts,
you can do it as follows:
[X,Y,Z] = peaks(20);
ax=nestedLayouts([2,2],[1,2]);
for i=[3,5,7]
ax(i).Layout.TileSpan=[1,2];
delete(ax(i+1));
end
surf(ax(1),X,Y,Z)
surf(ax(2),X,Y,Z)
contour(ax(3),X,Y,Z)
imagesc(ax(5),Z)
plot3(ax(7), X,Y,Z)
  2 件のコメント
Nooruddin Shaik
Nooruddin Shaik 2024 年 5 月 14 日
Thanks for the answer , but is fileexchange safe ??
Matt J
Matt J 2024 年 5 月 14 日
Well, I posted that particular file. So, yes, it is safe.

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

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by