Ylim is not working

조회 수: 39 (최근 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 CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by