Graphics Previous page   Next Page

Plotting with Two Y-Axes

The plotyy command enables you to create plots of two data sets and use both left and right side y-axes. You can also apply different plotting functions to each data set. For example, you can combine a line plot with a stem plot of the same data.

Combining Linear and Logarithmic Axes

You can use plotyy to apply linear and logarithmic scaling to compare two data sets having different ranges of values.

This example saves the handles of the lines and axes created to adjust and label the graph. First, label the axes whose y value ranges from 10 to 1000. This is the first handle in haxes because it was specified first in the call to plotyy. Use the axes command to make haxes(1) the current axes, which is then the target for the ylabel command.

Now make the second axes current and call ylabel again.

You can modify the characteristics of the plotted lines in a similar way. For example, to change the line style of the second line plotted to a dashed line, use the statement

See Using Multiple X- and Y-Axes for an example that employs double x- and y-axes.

See LineSpec for additional line properties.


Previous page  Plotting Imaginary and Complex Data Setting Axis Parameters Next page

© 1994-2005 The MathWorks, Inc.