PLOTYY Label Vertical Axis
38 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Walter Roberson
le 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 commentaires
Walter Roberson
le 5 Nov 2012
Modifié(e) : Walter Roberson
le 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Two y-axis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!