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!