Graphics |

**Adding a Subplot**

Add a second axes below the current axes using the **New** **Subplots** panel. Click the right-facing arrowhead next to **2D Axes** and move the mouse to darken two squares, one on top of the other. This creates a subplot axes below the existing axes. MATLAB resizes the existing axes so both fit in the figure.

Once MATLAB inserts the new axes, select its entry in the Plot Browser and then click **Add Data**.

When the Add Data to Axes dialog is displayed, enter the following values:

- Set
**X Data Source**to`x`

. - Set
**Y Data Source**to`sin(x).^3`

. - Click
**OK**to plot this data.

Now add another plot overlaid on the first by clicking **Add Data** again and specify the data to plot:

- Set
**X Data Source**to`x`

. - Set
**Y Data Source**to`sin(x).^9`

. - Click
**OK**to plot this data.

Select the plot labeled `sin(x).^9`

under the second axes in the Plot Browser. Set the **Plot Type **in the Property Editor to `Area`

.

**Setting Axis Limits**

Adjust the *x*-axis in both axes using the Property Editor.

- Select the first axes in the Plot Browser.
- Change
**X****Limits**to -7 and 7.

Repeat these steps for the second axes.

**Adding Titles and Labels**

Select the first axes in the Plot Browser and set the following properties in the Property Editor:

- Set
**Title**to`Even Powers`

. `Set`

**X Label**to`X`

.- Click the
**Y Axis**tab and set**Y****Label**to`Sine of X`

.

Select the second axes in the Plot Browser and set the following properties in the properties panel:

- Set
**Title**to`Odd Powers`

. - Set
**Axis label**to`Sine of X`

. - On the
**Y Axis**tab, set**Axis label**to`Sine of X`

.

Note that the Plot Browser reflects the new axes names.

The following picture shows the result of these steps.

Select the text of the *y*-axis label on the first axes (now labeled **Even Powers** in the Plot Browser) and click the **Inspector** button on the Property Editor. Set the `Rotation`

property to `0`

and reposition the text by hand.

To make more space for the *y*-axis label, which is now in a horizontal position, select the axes and move it to the right with the mouse.

Repeat this process for the second axes (labeled **Odd Powers** in the Plot Browser).

The repositioned text label now looks like the following picture.

Example -- Working with Plotting Tools | Example -- Plotting Workspace Variables |

© 1994-2005 The MathWorks, Inc.