How can i use both the left and right y axis on a single figure?

조회 수: 1 (최근 30일)
Bantan Glory
Bantan Glory 2016년 6월 1일
답변: Elias Gule 2016년 6월 2일
Hi. Av been trying to have multiple plots on a single graph using both the left and the right y axis but i can.t. Av even tried using the yyaxis command but it gives me an error. please what do I do?

답변 (3개)

Steven Lord
Steven Lord 2016년 6월 1일
The yyaxis function was introduced in release R2016a as indicated by the comment at the bottom of its documentation page. If you're using an older release take a look at the plotyy function and use hold on one or both of the axes then call plot with the appropriate axis handle as the first input argument to add a plot parented to the specified axes.
  댓글 수: 1
Bantan Glory
Bantan Glory 2016년 6월 1일
편집: Bantan Glory 2016년 6월 1일
Thanks very much. I have four functions to plot. I want to plot three on one y axis and one function on the other y axis. I just tried plotyy but it didn't work. It still gives me an error. Any help? Please can u show me an example of what your just explained?

댓글을 달려면 로그인하십시오.


Elias Gule
Elias Gule 2016년 6월 1일
try the plotyy command. In the command window type
doc plotyy
to see examples of how to use the function.
  댓글 수: 1
Bantan Glory
Bantan Glory 2016년 6월 1일
Thanks very much. I have four functions to plot. I want to plot three on one y axis and one function on the other y axis. I just tried plotyy but it didn't work. It still gives me an error. Any help?

댓글을 달려면 로그인하십시오.


Elias Gule
Elias Gule 2016년 6월 2일
Ok, try this:
x = linspace(0,2*pi,100);
y1 = 2*cos(x);
y2 = -2*sin(x);
y3 = 5*sin(2*x);
y4 = -10.5*sin(5*x);
[hAx,hLine1,hLine2] = plotyy([x' x' x'],[y1' y2' y3'],x,y4);
axis tight

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by