Ylim is not working

31 次查看(过去 30 天)
Yaser Khojah
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] )

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by