필터 지우기
필터 지우기

Setting y-axes range on plot with multiple x- axes

조회 수: 1 (최근 30일)
Andreas Volden
Andreas Volden 2014년 12월 15일
댓글: Andreas Volden 2014년 12월 16일
Hi! I'm having some issues regarding a plot with two x-axes and a similar y-axis. At least, that's what I want. My code from matlab looks like this:
t1 = [1:length(q_mean_norm)];
t2 = [1:length(q_mean_pc_dt_zero)];
figure(3)
xlabels{1} = 'q_mean_norm valid samples[s]';
xlabels{2} = 'q_mean_pc_dt_zero valid samples[s]';
ylabels{1} = 'Flow [l/min]';
ylabels{2} = 'Flow [l/min]';
[ax,hl1,hl2] = plotxx(t1,q_mean_norm,t2,q_mean_pc_dt_zero,xlabels,ylabels);
grid;
The problem is that my two y-axes in this case are different. The two functions have minor differences which in this case could be neglected. Hence it would be favourable to keep the y-axes limits the same, in this case [-100,2000], regardeless of the fact that the two x-axes don't match.
I've tried different commands to manipulate both y-axes without any luck. Any tips you got? Thanks!

채택된 답변

dpb
dpb 2014년 12월 15일
편집: dpb 2014년 12월 16일
...keep the y-axes limits the same, in this case [-100,2000]...
set(ax,'ylim',[-100 2000])
Alternatively, you can use linkaxes and then manipulate only one and the other will follow...
linkaxes(ax,'y')
ylim(ax(1),[-100 2000])
For some reason I've never fathomed, [x|y]ylim don't accept a vector of handles; you have to use set to do more than one at a time. linkaxes then lets you do just the one and use ylim as demonstrated but it's not a lot of help overall in reducing code as you then have to use the specific axes handle.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by