필터 지우기
필터 지우기

YY axis scale on plotyy

조회 수: 6 (최근 30일)
Louis Deslée
Louis Deslée 2015년 2월 17일
댓글: Louis Deslée 2015년 2월 17일
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

채택된 답변

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015년 2월 17일
Try to use
linkaxes(AX, 'xy')
  댓글 수: 1
Louis Deslée
Louis Deslée 2015년 2월 17일
Thank you very much, it is what I needed !!!
Have a nice day, louis

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by