nexttile
Creates axes in the next free tile of a tiled chart layout.
Category: Graphics > Formatting and Annotation
Syntax
nexttile
Creates axes in the next empty tile of the current layout, creating a 2-by-2 layout if none exists.
nexttile(n)
Uses tile number n, counted row by row from the top left.
nexttile(t, ___)
Works in the layout t instead of the current one.
ax = nexttile(___)
Returns the axes object.
Description
nexttile is the way to place plots in a layout. Without a number, it fills the grid in reading order, one tile per call. With a number, it jumps to a particular tile, which allows filling them in any order.
The axes it returns is current, so plot commands that follow draw into that tile.
Input arguments
t- Layout created by
tiledlayout. n- Tile number, a positive integer within the grid.
Output arguments
ax- Axes object that fills the tile and becomes the current axes.
Example
Two plots side by side
t = tiledlayout(1, 2);
ax1 = nexttile;
plot(1:5)
title('linear')
ax2 = nexttile;
plot((1:5).^2)
title('square')
class(ax1)
Output
ans = 'matlab.graphics.axis.Axes'