How can I increase the vertical size of subplots?
Ältere Kommentare anzeigen
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.
2 Kommentare
Paresh yeole
am 8 Jun. 2020
Try using :
set(gca,'Units','centimeters','Position', [0 0 7.5 6])
for each subplot.
NA
am 8 Jun. 2020
Akzeptierte Antwort
Weitere Antworten (1)
Bjorn Gustavsson
am 8 Jun. 2020
You can manually adjust the subplot's axes position like this:
sph = subplot(3,2,1);
dx0 = 0;
dy0 = -0.05;
dwithx = 0.0;
dwithy = 0.1;
set(sph,'position',get(sph,'position')+[dx0,dy0,dwithx,dwithy])
You will have to modify this heavily, but the tweaking shouldn't be too bad for one figure - and might be "impossible" to get right for an absolutely general sub-plots configuration.
There are a number of file-exchange contributions that handles this, or different parts of this:
gettightsubplothandles, tight_subplot, panel, tight-subplot-with-units-in-centimeter, border-less-tight-subplot.
Hopfully you find something useful.
HTH
1 Kommentar
NA
am 8 Jun. 2020
Kategorien
Mehr zu Subplots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

