Clear Filters
Clear Filters

PLOTYY Label Vertical Axis

66 views (last 30 days)
T
T on 5 Nov 2012
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?

Accepted Answer

Walter Roberson
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
T
T on 5 Nov 2012
perhaps I shold have used what was in the help menu,
what is stairs and plot were replaced with function1 and function2 what then would this represent? It doesn't even show up on the graph. If it instructs plotyy() to call function1() plot for the first data set, how do I access it?
Walter Roberson
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Two y-axis in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!