Tiledlayout: Make Plots of unequal width
32 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I want to use tiledlayout to place multiple graphs of unequal width. An example of what I'm trying to do is below. Using the figure command only seems to edit the entire box and I'm not sure how to make the tiledlayout command do what I want
Current figure:
Desired appearance (expertly edited using MS Paint)
Example code:
figure('Units','normalized','Position',[0.5,0.4,.5,.5]);
tiledlayout(1,2,'TileSpacing','Compact','Padding','Compact')
nexttile
plot(foo,bar)
%formatting stuff
nexttile
plot (foo2,bar2)
%formatting stuff
0 件のコメント
採用された回答
Mann Baidi
2024 年 6 月 13 日
編集済み: Mann Baidi
2024 年 6 月 13 日
I can observe that you would like to plot graphs with unequal width using "tiledlayout".
For plotting graph with unequal width, you will have to consider the figure as m x n matrices and then give width and height to different graphs accordingly. For your issue, you can refer to the following example.
% Create a 2x3 tiled layout
t = tiledlayout(2, 3);
% First plot (spans 2 rows and 1 column)
nexttile(t, [2, 1]);
plot(rand(10, 1));
title('Plot 1 (2 rows x 1 column)');
% Second plot (spans 2 rows and 2 columns)
nexttile(t, [2, 2]);
plot(rand(10, 1));
title('Plot 2 (1 row x 2 columns)');
You can explore more about tiledlayout using the link mentioned below:
0 件のコメント
その他の回答 (1 件)
Tony
2024 年 6 月 13 日
If your sizing is small integer ratios, then you can control the size of the group of tiles the individual plots span
plot_spans = [2 1 ; 2 2]; % first plot is half as wide as second
figure('Units','normalized','Position',[0.5,0.4,.5,.5]);
tiledlayout(max(plot_spans(:,1)), sum(plot_spans(:,2)), 'TileSpacing','Compact','Padding','Compact')
nexttile(plot_spans(1,:)) % number of rows and columns the plot should span
%plot(foo,bar)
%formatting stuff
nexttile(plot_spans(2,:))
%plot (foo2,bar2)
%formatting stuff
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!