problem with 2nd axis Yticks with plotyy and semilogy

10 vues (au cours des 30 derniers jours)
Ronald Haynes
Ronald Haynes le 2 Mai 2015
Réponse apportée : dpb le 2 Mai 2015

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 commentaires
Ronald Haynes
Ronald Haynes le 2 Mai 2015
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 le 2 Mai 2015
No figure attached...

Connectez-vous pour commenter.

Réponse acceptée

dpb
dpb le 2 Mai 2015
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.

Plus de réponses (0)

Catégories

En savoir plus sur Two y-axis dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by