フィルターのクリア

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

3 ビュー (過去 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.
  1 件のコメント
Andreas Volden
Andreas Volden 2014 年 12 月 16 日
Thanks for that input. Works great!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by