How do use 'flow' in a tiled plot while forcing a maximum of 2 columns?

조회 수: 9 (최근 30일)
Rafael Cordero
Rafael Cordero 2023년 3월 23일
편집: Adam Danz 2023년 3월 23일
Hello folks,
I want to produce a series of tiled plots. Problem is, I do not know a priori the number of tiles. In this sense, 'flow' is very helpful. However, I want the tiles constrained to two columns, so that the tiles could possibly exist dynamically as [2 x1], [2 x 2], [2 x 3], [2 x 4] etc.
Is it possible to do this?
Thank you!
PS: I have R2022b so cant use 'Vertical'

답변 (1개)

Adam Danz
Adam Danz 2023년 3월 23일
편집: Adam Danz 2023년 3월 23일
A flow arrangement with a fixed number of columns (or rows) greater than 1 is not currently available. A new feature in MATLAB R2023a is the Vertical and Horizontal flow arrangements that allow for 1xn or nx1 flexible flow.
If you're using R2023a or later, you could arrange two tiledlayout objects that each have a nx1 vertical arrangement.
Here's a demo:
% Set up figure
figure()
tclmain = tiledlayout(1,2);
tclLeft = tiledlayout(tclmain,'vertical');
tclLeft.Layout.Tile = 1;
tclRight = tiledlayout(tclmain,'vertical');
tclRight.Layout.Tile = 2;
% create a random number of plots
nPlots = randi(5)+4;
for n = 1:nPlots
% Select right column if n is odd
% otherwise select left column
if mod(n,2)==0
tcl = tclRight;
else
tcl = tclLeft;
end
ax = nexttile(tcl);
plot(ax,fft(eye(randi(10)+1)))
end
drawnow
% Make sure the right column has an equal number of tiles
% as the left column.
if tclRight.GridSize(1) < tclLeft.GridSize(1)
nexttile(tclRight)
end

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by