Hello, I am trying to align two subplots; a bar and a bar plots. Thus, I used position but I still find them not alighted. Could you please help
x_value = [1;2;3;4];Analyti = [9343300000.00000;9343300000.00000;9343300000.00000;9343300000.00000];NPV_all = [10098480743.4960, 9405675708.82828, 9345356723.26658, 9343358602.05035];period = [0.109958329319958 0.00747830013942861 0.0753802706146702 1.68890524065252];figuresubplot(2,1,1)ylabel('NPV ($B)')plot(x_value, Analyti /10^9,'--k'); hold onp1 = plot(x_value, NPV_all'/10^9); hold onhp = gca; posn1 = hp.Position; title('Impact of Discretizaion on NPV')legend('Discrete NPV','continuous NPV', 'Analytical NPV')xlabel('Discrete Time Method')xticks([1:4])xticklabels({'Years','Months','Days','Hours'})ylim([8,11])subplot(2,1,2)p2 = bar(period); hold onxticks([1:4])xticklabels({'Years','Months','Days','Hours'})ylabel('Seconds')xlabel('Discrete Time Method')hp2 = gca; posn2 = hp2.Position; set(hp2,'Position',[posn2(1:2), posn1(3:4)])
Best Answer