Setting y-axes range on plot with multiple x- axes
1 回表示 (過去 30 日間)
古いコメントを表示
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!
0 件のコメント
採用された回答
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!