PLOTYY Label Vertical Axis
66 views (last 30 days)
Show older comments
figure (7)
plotyy(x1-11100,y1,x2,y2, 'stairs', 'plot')
Is 'stairs' 'plot' really necessary? What do these represent in plotyy?
title('Force vs. Time')
xlabel('Time (s)');
How would I label the left and right vertical axis?
0 Comments
Accepted Answer
Walter Roberson
on 5 Nov 2012
'stairs' in that position instructs plotyy() to call stairs() plot for the first set of data. Use whichever plotting routine is appropriate for your data representation.
To label the two axes independently, record the output of plotyy()
ax = plotyy(x1-11100,y1,x2,y2, 'stairs', 'plot');
Then index result to specify which axis you want
ylabel(ax(1), 'Major Force');
ylabel(ax(2), '2 Star General Force');
2 Comments
Walter Roberson
on 5 Nov 2012
Edited: Walter Roberson
on 6 Nov 2012
As the help says,
plotyy(X1,Y1,X2,Y2,FUN) uses the plotting function FUN
instead of PLOT to produce each graph. FUN can be a
function handle or a string that is the name of a plotting
function, e.g. plot, semilogx, semilogy, loglog, stem,
etc. or any function that accepts the syntax H = FUN(X,Y).
For example
plotyy(X1,Y1,X2,Y2,@loglog) % Function handle
plotyy(X1,Y1,X2,Y2,'loglog') % String
Make sure that you use the @ form if you are calling a local function; the string form will only work if the name of the function is known at the base workspace level (e.g. a .m file with the name exists). The function so called would have to contain calls to graphics routines such as line() to do the actual graphing.
More Answers (0)
See Also
Categories
Find more on Two y-axis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!