MATLAB: How to increase the vertical size of subplots

for loopsubplot sizesubplots

Hi,
I'm trying to increase the verticle size of my subplots, but I'm having no luck. Can someone please let me know where I've gone wrong.
My code is:
suplotTitle = {'0.4mA', '0.6mA', '0.8mA', '1.2mA', '1.6mA'};
f1=figure('position', [10, 10, 800, 1000]);
for ii=1:5
subplot(6,2,2*ii-1);
b1 = bar(conRR(2:end,1), conRR(2:end,ii+1));
b1.FaceColor = '#D95319';
b1.EdgeColor = 'none';
xticks(1:1:16);
ylim([0 80]);
title(suplotTitle{ii})
set(gca, 'FontSize', 10);
box off
if ii < 5
set(gca,'XTick', []);
end
end
subplot(6,2,5), ylabel('Respiratory Rate (BPM)')
subplot(6,2,9), xlabel('Number of rats (N)')
for ii=1:5
s2 = subplot(6,2,2*ii);
b2 = bar(b9RR(2:end,1), b9RR(2:end,ii+1));
b2.FaceColor = '#0072BD';
b2.EdgeColor = 'none';
xticks(1:1:16);
ylim([0 80]);
title(suplotTitle{ii})
box off
set(gca, 'FontSize', 10);
if ii < 5
set(gca,'XTick', []);
end
end
subplot(6,2,6), ylabel('Respiratory Rate (BPM)');
subplot(6,2,10), xlabel('Number of rats (N)');
%Add legend
hL = subplot(6,2,[11,12]);
poshL = get(hL,'position');
lgd = legend(hL,[b1,b2],'Control','Intervention');
legend box off;
set(lgd,'position',poshL,'Orientation','horizontal', 'FontSize', 12);
axis(hL,'off'); % Turning its axis off
%Add main title
t = sgtitle('Respiratory Rate');
t.FontSize = 15;
t.FontWeight = 'bold';
At the moment my Figure looks like this:
Thanks in advance.

Best Answer

I got this to work with the previous code, however I couldn’t get it to work with the code you posted. You will need to make the appropriate adjustments to do that.
The change is to add these two lines in each looop:
PosVec = Ax.Position;
Ax.Position = PosVec+[0 -0.005 0 0.005];
and after both loops:
f1.Position = f1.Position+[0 -300 0 300];
That should get you started.
The (Revised) Code —
conRR = [(0:10).' rand(11,5)*80]; % Create Matrix

b9RR = [(0:10).' rand(11,5)*80]; % Create Matrix
suplotTitle = {'0.4mA', '0.6mA', '0.8mA', '1.2mA', '1.6mA'};
f1=figure
for ii=1:5
Ax = subplot(5,2,2*ii-1);
b1 = bar(conRR(2:end,1), conRR(2:end,ii+1));
b1.FaceColor = '#D95319';
b1.EdgeColor = 'none';
xticks(1:1:16);
ylim([0 80]);
title(suplotTitle{ii})
PosVec = Ax.Position;
Ax.Position = PosVec+[0 -0.005 0 0.005];
end
for ii=1:5
Ax = subplot(5,2,2*ii);
b2 = bar(b9RR(2:end,1), b9RR(2:end,ii+1));
b2.FaceColor = '#0072BD';
b2.EdgeColor = 'none';
xticks(1:1:16);
ylim([0 80]);
title(suplotTitle{ii})
PosVec = Ax.Position;
Ax.Position = PosVec+[0 -0.005 0 0.005];
end
f1.Position = f1.Position+[0 -300 0 300];
The Plots —
Original:
This code: