Search code examples
matlabplotmatlab-figure

How to merge tiles created by "tiledLayout" in MATLAB?


In MATLAB when working with subplot I can merge axes from different subplots to create a larger subplot like:

x = 1:10;
figure
subplot(131)
plot(x)
subplot(1,3,2:3)
plot(x+2)

Now that MATLAB has introduced tiledlayout, I am using it instead of subplot as it allows the user to modify the gap between various axes in a figure. But I cannot figure out how I can merge different tiles to create a larger tile. Is there any way I can combine different tiles created by tiledlayout to create a larger tile (basically, I am looking for the equivalent of subplot(1,3,2:3))?


Solution

  • Take a look at nexttile and the various ways to call it. Take for example the documentation of nexttile(span) which says:

    Tile span, specified as a vector of the form [r c], where r and c are positive whole numbers. Use this argument to make the axes span r rows by c columns of tiles in the layout.

    and the following demonstration is shown:

    enter image description here