YY axis scale on plotyy
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Louis Deslée
am 17 Feb. 2015
Kommentiert: Louis Deslée
am 17 Feb. 2015
hi everyone,
I am using the function plotyy in order to display dynamic of two different temperatures. Since it's two quantities in °C, I want the scales to be the same on each axis and the zero at the same level. I know wery well that I could plot the two dynamic on the same y-axis but I really want it on two different axis ! Here is the code :
% dynamique TA et TS5
d=d+1;
figure (d); [AX,H1,H2]=plotyy(meteo.data(:,Idxdate_meteo),meteo.data(:,Idx_TA),meteo.data(:,Idxdate_meteo),meteo.data(:,Idx_TS5),'plot');
xlabel('Mois','FontSize',20);
datetick(AX(1),'x','mmm');
set(AX(2),'XTick',[])
set(AX,{'ycolor'},{[0.1765 0.5294 0.9116];[0.1725 0.4353 0.1098]},'FontSize',14)
set(H1,'color',[0.1765 0.5294 0.9116])
set(H2,'color',[0.1725 0.4353 0.1098])
set(get(AX(1),'Ylabel'),'String','Tair [°C]','FontSize',20)
set(get(AX(2),'Ylabel'),'String','Tsol à 5cm [°C]','FontSize',20)
%aligner les zeros
maxval = cellfun(@(X) max(abs(X)), get([H1 H2], 'YData'));
ylim = [-maxval, maxval] * 1.1; % Mult by 1.1 to pad out a bit
set(AX(1), 'YLim', ylim(1,:) );
set(AX(2), 'YLim', ylim(2,:) );
And here is what I get :
X-axis doesn't need to change. I guess I have to use the axis function but I dont know how to use it to change scales of the both y-axis only. For example I want the both y-axis scales with min = -5°C and max = 50°C.
Thank you for your time, Louis
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!