6.6. Sub-Plots

A graphic window can be subdivided into many sub-graphs or sub-plots using subplot command. The command subplot(i, j, k) splits the figure window into (i × j) parts of plotting areas with each treated as a subplot and selects the kth area for the current plot. The subplots are numbered starting from top row left to right then along the second row and so on. For example: The following commands:

subplot(2,1,1);
plot (profit);
subplot(2,1,2);
plot (loss);

when executed will divide the figure window into (2 × 1) parts of plotting area that is, two sub-windows (two rows and one column), and will plot profit in the top half of the window and loss on the bottom half.

The command subplot(2, 2, 3); plot(x, y) will divide the figure window ...

Get MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.