This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Create Figure with Multiple Axes Using Subplots

This example shows how to create a figure containing multiple axes using the subplot function. The syntax, subplot(m,n,p), divides the figure into an m-by-n grid with an axes in the pth grid location. The grids are numbered along each row.

Create Subplots and Add Subplot Titles

Use subplot to create a figure containing a 2-by-2 grid of graphs. Plot a sine wave in the first subplot. Then, plot three more sine waves in the second, third, and fourth subplots.

x = linspace(-5,5);
y1 = sin(x);
title('First subplot')

y2 = sin(2*x);
title('Second subplot')

y3 = sin(4*x);
title('Third subplot')

y4 = sin(6*x);
title('Fourth subplot')

Add Subplot Axis Labels

Add subplot labels using the xlabel and ylabel functions. By default, xlabel and ylabel label the current axes. The current axes is typically the last axes created or clicked with the mouse. Reissuing the command, subplot(m,n,p), makes the pth subplot the current axes.

Make the third subplot the current axes. Then, label its x-axis and y-axis.


See Also

| | | | |

Related Examples

Was this topic helpful?