The Wayback Machine - https://web.archive.org/web/20110828170309/http://www.mathworks.com:80/help/techdoc/creating_plots/f9-43464.html
Skip to Main Content Skip to Search
Product Documentation

Example — Working with Plotting Tools

Identifying Workspace Data to Plot

This example illustrates how to use the plotting tools to graph a workspace variable versus an expression typed into the Add Data to Axes dialog.

Create a variable in the workspace,

x = -2*pi:pi/25:2*pi;

Use the plottools command to create a figure group with the plotting tools attached.

plottools

Click 2D Axes in the New Subplot panel of the Figure Palette.

Once the axes appears, the Add Data button on the Plot Browser is activated.

Click this button to display the Add Data to Axes dialog. When the Add Data to Axes dialog is displayed, enter the following values:

A plot of sin(x).^2 versus x appears.

Now add another plot to the same axes. Click Add Data again and specify the data to plot:

Select the last plot (the green line) and set the Plot Type in the Property Editor to Stem. The plot should now look like the following picture.

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. The existing axes resize so both fit in the figure.

In the inserted 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:

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

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.

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:

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

The Plot Browser now 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 More Properties 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.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A; sessions led by MATLAB experts.

 © 1984-2011- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS