Tiledlayout: Make Plots of unequal width
38 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Mann Baidi
on 13 Jun 2024
Edited: Mann Baidi
on 13 Jun 2024
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 Comments
More Answers (1)
Tony
on 13 Jun 2024
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 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!