Create graphs with y axes on both left and right side
Syntax
plotyy(X1,Y1,X2,Y2)
plotyy(X1,Y1,X2,Y2,'function')
plotyy(X1,Y1,X2,Y2,'function1','function2')
[AX,H1,H2] = plotyy(...)
Description
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 plotting function specified by the string 'function
' instead of plot
to produce each graph. 'function
' can be plot
, semilogx
, semilogy
, loglog
, stem
or any MATLAB function that accepts the syntax:
h = function(x,y)
plotyy(X1,Y1,X2,Y2,'function1','function2')
uses function1(X1,Y1)
to plot the data for the left axis and function1(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.
Examples
Create a graph using the plot function and two y-axes:
t = 0:pi/20:2*pi;
y1 = sin(t);
y2 = 0.5*sin(t-1.5);
plotyy(t,y1,t,y2,'plot')
See Also
plot
, loglog
, semilogx
, semilogy
, Axes properties: XAxisLocation
, YAxisLocation
The Axes chapter in the Using MATLAB Graphics manual for information on multi-axis axes.
[ Previous | Help Desk | Next ]