How to control dual Y axis

조회 수: 2 (최근 30일)
SASASA
SASASA 2014년 4월 30일
편집: dpb 2015년 2월 12일
Hi there! For only one set of data, I need a dual Y axis label ( Centigrade and Fahrenheit, nothing fancy). Following this:
I managed to get the second axis from 0 to 1. But I can't seam able to modify it to get the Fahrenheit scale.
Since is quite a simple problem, I just need another label, I would prefer, if possible,not to get into plotyy and just work with labels.
One last thing, I do need however to export the plot to a pdf to put into latex. I'm currently using
saveas(/path/file.pdf,'pdf')
combined with
set(gcf,'papersize',[10,7])
set(gcf,'paperposition,[0,0,10,17]')
So any solution should be compatible with that..
Well, thanks everyone for their time in advance.

채택된 답변

dpb
dpb 2014년 4월 30일
...I just need another label, I would prefer, if possible,not to get into plotyy and just work with labels...
Compared to what you've already done, plotyy is trivial. There's no reason not to use it.
As a way to approach it, try the following--
A) make up some data and plotyy it to get a couple axes...
x=1:10;
tf=20*rand(size(x))+72;
tc=(tf-32)/1.8;
hA=plotyy(x,tf,x,tc);
B)
Set limits on the LH axes to round nos in F...
ylim(hA(1), [32 212]) % pick a couple convenient points
set(hA(1),'ytick',30:20:210) % and label
C) now scale the RH axis to match...
ylimF=get(hA(1),'ylim'); % the F limits in general
set(hA(2),'ylim',(ylimF-32)/1.8) % set the C to the same range
set(hA(2),'ytick',[0:10:100]) % and set some ticks
The problem w/ the above is that the two numbers aren't the same number of tick marks on the two axes, but that's kinda' hard to fix for all cases with round numbers given the relative scaling.
Bout the best you can do is use the same number of ticks and round the decimals on the one you choose as secondary to be reasonable unless your scale is one where it's possible to have the intersection points of integer values in the two scales match up.
I don't understand what problem there is in saving the figure???
  댓글 수: 1
SASASA
SASASA 2014년 5월 3일
편집: dpb 2015년 2월 12일
Hi there! First of all THX a lot for your answer. Under your construction I've tried this but didn't work
hA=plotyy(tiempor(ti(1):tf(1)), eTNSpromr(ti(1):tf(1)), ...
tiempor(ti(1):tf(1)),(eTNSpromr(ti(1):tf(1))-32)/1.8);
ylim(hA(1), [1 600]) % pick a couple convenient points
set(hA(1),'ytick',30:20:210) % and label
ylimF=get(hA(1),'ylim'); % the F limits in general
set(hA(2),'ylim',(ylimF-32)/1.8) % set the C to the same range
set(hA(2),'ytick',[0:10:100]) % and set some ticks
were "tiempor" is my dominion and "eTNSpromr" is my temperature data. Am I doing something wrong?

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

추가 답변 (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