필터 지우기
필터 지우기

using hold on with plotyy

조회 수: 8 (최근 30일)
Rory
Rory 2011년 9월 23일
I couldn't find an answer out there, so i'll ask:
I want to plot into one axis many curves (by using a loop), using hold on. How do I use 'hold on' separately for each axis of plotyy?
Then, after this loop, I want to plot a set of points into the second y axis. The set of points does not exist until the loop is done. how do I use plotyy without initially plotting into both axes? can i plot into the second axes afterwards like this?
thanks in advance

채택된 답변

the cyclist
the cyclist 2011년 9월 23일
plotyy() creates two axes on top of each other. The syntax
>> [ax h1 h2] = plotyy(x1,y1,x2,y2);
will put the handles to both axes in the variable "ax". Then you can use the syntax
>> hold(ax(1),...)
or
>> hold(ax(2),...)
to apply the hold to ones set of axes or the other.
  댓글 수: 1
Fangjun Jiang
Fangjun Jiang 2011년 9월 23일
+1, nice cyclist! Thank you!

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

추가 답변 (1개)

Rory
Rory 2011년 9월 26일
I also found the clear axes command 'cla' to be useful for this: I set up plotyy with two arbitrary X's an Y's, then go in and clear each axis:
[ax h1 h2]=plotyy([0,1],[0,1],[0,1],[0,1]); axes(ax(1)) cla axes(ax(2)) cla
axes(ax(1)); %make axis 1 the current axis hold(ax(1); now populate the first axis
axes(ax(2)); %make axis 2 the current axis hold(ax(2)); and finally populate the second axis.

카테고리

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