| MATLAB Function Reference | ![]() |
![]()
To graph selected variables, use the Plot Selector
in the Workspace Browser, or use the
Figure Palette Plot Catalog. Manipulate graphs in plot edit mode with the Property Editor. For details, see Plotting Tools — Interactive Plotting in the MATLAB® Graphics documentation and Creating Plots from
the Workspace Browser in the MATLAB Desktop
Tools documentation.
plotyy(X1,Y1,X2,Y2)
plotyy(X1,Y1,X2,Y2,function)
plotyy(X1,Y1,X2,Y2,'function1','function2')
[AX,H1,H2] = plotyy(...)
plotyy(X1,Y1,X2,Y2) plots X1 versus Y1 with y-axis labeling on the left and plots X2 versus Y2 with y-axis labeling on the right.
plotyy(X1,Y1,X2,Y2,function) uses the specified plotting function to produce the graph.
function can be either a function handle or a string specifying plot, semilogx, semilogy, loglog, stem, or any MATLAB function that accepts the syntax
h = function(x,y)
For example,
plotyy(x1,y1,x2,y2,@loglog) % function handle plotyy(x1,y1,x2,y2,'loglog') % string
Function handles enable you to access user-defined subfunctions and can provide other advantages. See @ for more information on using function handles.
plotyy(X1,Y1,X2,Y2,'function1','function2') uses function1(X1,Y1) to plot the data for the left axis and function2(X2,Y2) to plot the data for the right axis.
[AX,H1,H2] = plotyy(...) returns the handles of the two axes created in AX and the handles of the graphics objects from each plot in H1 and H2. AX(1) is the left axes and AX(2) is the right axes.
This example graphs two mathematical functions using plot as the plotting function. The two y-axes enable you to display both sets of data on one graph even though relative values of the data are quite different.
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','Slow Decay') set(get(AX(2),'Ylabel'),'String','Fast Decay')
Use the xlabel and title commands to label the x-axis and add a title:
xlabel('Time (\musec)')
title('Multiple Decay Rates') Use the line handles to set the LineStyle properties of the left- and right-side plots:
set(H1,'LineStyle','--') set(H2,'LineStyle',':')

plot, loglog, semilogx, semilogy, axes properties XAxisLocation, YAxisLocation
See Using Multiple X- and Y-Axes for more information.
![]() | plottools | pol2cart | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |