problem with 2nd axis Yticks with plotyy and semilogy

조회 수: 11 (최근 30일)
Ronald Haynes
Ronald Haynes 2015년 5월 2일
답변: dpb 2015년 5월 2일

Hi folks, I was hoping the following code:

[ax,h1,h2]=plotyy([overlap,overlap],[error{2},error{3}], ...
                    overlap,initial,'semilogy','semilogy');
set(ax(1),'YLim',[10.^(-15) 10.^(-1)]);
set(ax(1), 'YTick', [10.^(-15) 10.^(-13) 10.^(-11) 10.^(-9) ...
                     10.^(-7)  10.^(-5)  10.^(-3)  10.^(-1)])
set(ax(2),'YLim',[10.^(-6)  10.^(-2)]);
set(ax(2),'YTick', [10.^(-6) 10.^(-5) 10.^(-4) 10.^(-3) 10.^(-2)]);

Would put the 10^(-6) ... 10^(-2) ticks on the right y axis of the plot. Instead I get the attached plot. Any suggestions?

  댓글 수: 2
Ronald Haynes
Ronald Haynes 2015년 5월 2일
My plot is not appearing! the tick marks I am seeing are 1e-06, 3.16228e-06, 1e-05,3.16228e-05 and 0.0001
Very strange!
dpb
dpb 2015년 5월 2일
No figure attached...

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

채택된 답변

dpb
dpb 2015년 5월 2일
Don't have your data to play with specifically, but a dummy set
>> y1=logspace(-1,-15,10).*rand(1,10);
>> y2=logspace(-2,-6,10).*rand(1,10);
>> hAx=plotyy(1:10,y1,1:10,y2,@semilogy,@semilogy);
>> ylim(hAx(1),[1e-15 1e-1])
>> set(hAx(1),'ytick',[1e-15, 1e-10 1e-5 1e-1])
>> ylim(hAx(2),[1e-6 1e-2])
>> set(hAx(2),'ytick',[1e-6, 1e-4 1e-2])
>>
has the expected result here. Of course, since there aren't the same number of ticks on the LH and RH axes you'll have the resulting "extra" tick on the RH axis corresponding to the location of the intermediaries on the left--this is a fignewton of the Matlab graphics that can't really be avoided.

추가 답변 (0개)

카테고리

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