Ylim is not working

41 ビュー (過去 30 日間)
Yaser Khojah
Yaser Khojah 2019 年 3 月 25 日
コメント済み: Yaser Khojah 2019 年 3 月 25 日
I have tried to inlcude a common and fixed Y-axis and X-axis for all the figures but it is working. Can you please help.
figure
N_F =1;
subplot(3,1,1);
idx_1 = MaT_All(:,1) == Median_All(1) & MaT_All(:,2) ~= Median_All(2) & MaT_All(:,3) ~= Median_All(3) & MaT_All(:,4) ~= Median_All(4)...
& MaT_All(:,5) ~= Median_All(5) & MaT_All(:,6) ~= Median_All(6) & MaT_All(:,7) ~= Median_All(7) & MaT_All(:,8) ~= Median_All(8);
Mat_1 = MaT_All(idx_1,:);
scatter(MaT_All(idx_1,18),MaT_All(idx_1,17)); hold on;
title(sprintf('Impact of r* on Field %d',N_F))
xlabel('Risk ($B)')
ylabel('E(NPV) ($B)')
legend(sprintf('Medain Only of Field %d',N_F))
ylim([-50 50])
N_F =2;
subplot(3,1,2);
idx_2 = MaT_All(:,1) ~= Median_All(1) & MaT_All(:,2) == Median_All(2) & MaT_All(:,3) ~= Median_All(3) & MaT_All(:,4) ~= Median_All(4)...
& MaT_All(:,5) ~= Median_All(5) & MaT_All(:,6) ~= Median_All(6) & MaT_All(:,7) ~= Median_All(7) & MaT_All(:,8) ~= Median_All(8);
Mat_2 = MaT_All(idx_2,:);
scatter(MaT_All(idx_2,18),MaT_All(idx_2,17)); hold on;
title(sprintf('Impact of r* on Field %d',N_F))
xlabel('Risk ($B)')
ylabel('E(NPV) ($B)')
legend(sprintf('Medain Only of Field %d',N_F))
ylim([-50 50])
N_F =8;
subplot(3,1,3);
idx_8 = MaT_All(:,1) ~= Median_All(1) & MaT_All(:,2) ~= Median_All(2) & MaT_All(:,3) ~= Median_All(3) & MaT_All(:,4) ~= Median_All(4)...
& MaT_All(:,5) ~= Median_All(5) & MaT_All(:,6) ~= Median_All(6) & MaT_All(:,7) ~= Median_All(7) & MaT_All(:,8) == Median_All(8);
Mat_8 = MaT_All(idx_8,:);
scatter(MaT_All(idx_8,18),MaT_All(idx_8,17)); hold on;
title(sprintf('Impact of r* on Field %d',N_F))
xlabel('Risk ($B)')
ylabel('E(NPV) ($B)')
legend(sprintf('Medain Only of Field %d',N_F))
ylim([-50 50])

採用された回答

Adam
Adam 2019 年 3 月 25 日
Use explicit axes handles for plotting instructions and instructions like hold, ylim, xlim. i.e.
hAxes(1) = subplot(3,1,1);
scatter( hAxes(1),... );
ylim( hAxes(1),... );
...
hAxes(2) = subplot(3,1,2);
...
You may also find
doc linkaxes
useful if you want your axes to all have the same limits. If you store your axes handles in an array as shown above then you can simply replace all the individual ylim instructions with
linkaxes( hAxes, 'y' )
ylim( hAxes(1), [-50 50] )
  1 件のコメント
Yaser Khojah
Yaser Khojah 2019 年 3 月 25 日
Thanks Adam for your help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by