tiledlayout("vertical") with multiple columns

7 views (last 30 days)
Hi,
I want to create a figure with a tiledlayout("vertical") meaning that new rows can be added with nexttile() at a later time. However this layout should have multiple columns per row (the number of columns stays the same in each row - however I do not know how many rows will be added in the end). Do you know of a way how this is possible?
I tried nesting layouts but that didn't work well - see following code:
ff = figure()
T=tiledlayout(ff, "vertical");
nexttile(T,[1,1]); axis off
t1=tiledlayout(T, "horizontal"); %first inner layout
nexttile(t1)
nexttile(t1)
nexttile(T); axis off
t2=tiledlayout(T, "horizontal"); %first inner layout
nexttile(t2)
Thanks a lot,
Andreas

Answers (1)

Star Strider
Star Strider on 12 Sep 2025
I am not certain that tiledlayout can easily do what you want.
It might be easier to use subplot instead. That way, you can iteratively add rows and columns without knowing the number of subplots you may have initially.
  1 Comment
Walter Roberson
Walter Roberson on 12 Sep 2025
subplot() lays out the position of the axes at the time subplot() is called. If you call subplot(1,2,1) to place on the right hand side of the first row, and you later expand to two rows and so call subplot(2,2,4) to place on the right hand side of the new second row... then the subplot(1,2,1) will partially underlay the calculated position of subplot(2,2,4), resulting in subplot() removing the old subplot(1,2,1) axes. subplot() will not move the existing plots.

Sign in to comment.

Products


Release

R2025a

Community Treasure Hunt

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

Start Hunting!