plotting 2 lines and one bar with 2 y-axes

2 vues (au cours des 30 derniers jours)
Dan
Dan le 12 Mar 2013
Hello,
I'm trying to make a plot with two y-axes but three variables. So, on the first y-axis I want a line and a bar, and for the second y-axis just a line. I can't seem to figure this out with plotyy or plotyyy.
For a bar and line with plotyy I can use this code:
[ax,h1,h2] = plotyy(x1,y1,x2,y2,@bar,@line);
But this does not work with plotyyy:
[ax,hlines] = plotyyy(x1,y1,x2,y2,x3,y3,@bar,@line,@line);
Any suggestions would be greatly appreciated.
Thanks, Dan

Réponse acceptée

Walter Roberson
Walter Roberson le 12 Mar 2013
[ax,h1,h2] = plotyy(x1,y1,x3,y3,@bar,@line); %note x3 y3
hold(ax(1), 'on');
plot(ax(1), x2, y2); %on first axis
  1 commentaire
Dan
Dan le 12 Mar 2013
Perfect, thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

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!

Translated by