% File: http://web.mit.edu/8.13/matlab/Examples/plotmultipleaxes.m % Author: Taken from Matlab Documentation, 'doc plotyy' % Date: 2008-July-16 x = 0:0.01:20; y1 = 200*exp(-0.05*x).*sin(x); y2 = 0.8*exp(-0.5*x).*sin(10*x); [AX,H1,H2] = plotyy(x,y1,x,y2,'plot'); % You can use the handles returned by plotyy to label the axes and set the line styles used for plotting. With the axes handles you can specify the YLabel properties of the left- and right-side y-axis: set(get(AX(1),'Ylabel'),'String','Left Y-axis') set(get(AX(2),'Ylabel'),'String','Right Y-axis') % Use the xlabel and title commands to label the x-axis and add a title: xlabel('Zero to 20 \musec.') title('Using plotyy to plot both y-axes when data sets have very different scaling') % Use the line handles to set the LineStyle properties of the left- and right-side plots: set(H1,'LineStyle','--') set(H2,'LineStyle',':')