How to control dual Y axis

2 Ansichten (letzte 30 Tage)
SASASA
SASASA am 30 Apr. 2014
Bearbeitet: dpb am 12 Feb. 2015
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.

Akzeptierte Antwort

dpb
dpb am 30 Apr. 2014
...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 Kommentar
SASASA
SASASA am 3 Mai 2014
Bearbeitet: dpb am 12 Feb. 2015
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?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Two y-axis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by