next up previous contents
Next: 2.1.3.2 Histograms Up: 2.1.3 Other 2-D plots Previous: 2.1.3 Other 2-D plots   Contents

2.1.3.1 Double y-axis plots

The plotting command plotyy allows one to plot two different data sets (with the same range in the dependent variable) on the same plot but with different scales for the $y$-axes.
% Double y axes plot; Also demonstrate subplots
x = -10:.1:10; % define points for independent variable
y1 = (sin(x)./x).^2; % "dot" operator squares individual elements 
                     % and not the whole array
y2 = 3*sin(abs(x));
subplot(2,1,1); % Divide figure into 1x2 array of plots and start with #1
plot(x,y1,x,y2); % Plot both data sets an same scale
subplot(2,1,2); % Put next plot in second slot
plotyy(x,y1,x,y2) 
Note the different scales on each side of the plot on the bottom.

Gus Hart 2005-01-28