MATLAB: Repositioning multiple subplots – not all plots appearing

multiplesubplot

I'm doing multiple subplots (72 in total) over a 12 by 12 grid. I'm trying to plot them and then position them such that the plots are edge to edge. The problem I'm having is that when I reposition them some of the plots disappear. I paste the first part of the code below, I get to the eighth plot and then each time I add a new plot, the last plot disappears (eg, when I add p9, p8 disappears).
samps=load('data');
colormap jet
set(0,'DefaultAxesFontSize',10,'DefaultAxesFontName','Times New Roman','DefaultTextFontName','Times New Roman');
figure
p1=subplot(12,12,1)
histogram(exp(samps(:,1)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
ylabel('A_0','Interpreter','LaTex')
set(p1,'pos',[0.04,0.92,0.08,0.08])
p2=subplot(12,12,14)
histogram((samps(:,2)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
set(p2,'pos',[0.12,0.84,0.08,0.08])
p3=subplot(12,12,27)
histogram((samps(:,3)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
set(p3,'pos',[0.2,0.76,0.08,0.08])
p4=subplot(12,12,40)
histogram((samps(:,4)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
set(p4,'pos',[0.28,0.68,0.08,0.08])
p5=subplot(12,12,53)
histogram((samps(:,5)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
set(p5,'pos',[0.36,0.6,0.08,0.08])
p6=subplot(12,12,66)
histogram((samps(:,6)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
set(p6,'pos',[0.44,0.52,0.08,0.08])
p7=subplot(12,12,79)
histogram((samps(:,7)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
set(p7,'pos',[0.52,0.44,0.08,0.08])
p8=subplot(12,12,92)
histogram((samps(:,8)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
set(p8,'pos',[0.6,0.36,0.08,0.08])
p9=subplot(12,12,105)
histogram(exp(samps(:,9)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
set(p9,'pos',[0.68,0.28,0.08,0.08])
p10=subplot(12,12,118)
histogram((samps(:,10)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
set(p10,'pos',[0.76,0.2,0.08,0.08])
p11=subplot(12,12,131)
histogram(exp(samps(:,11)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
set(p11,'pos',[0.84,0.12,0.08,0.08])
p12=subplot(12,12,144)
histogram((samps(:,12)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
xlabel('$\gamma$','Interpreter','LaTex')
set(p12,'pos',[0.92,0.04,0.08,0.08])

Best Answer

If you're setting all of the positions manually, then subplot isn't really doing anything for you. You might consider just calling axes directly.
axes('Position',[0.04,0.92,0.08,0.08])
histogram(exp(samps(:,1)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
ylabel('A_0','Interpreter','LaTex')
axes('Position',[0.12,0.84,0.08,0.08])
histogram((samps(:,2)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
axes('Position',[0.2,0.76,0.08,0.08])
histogram((samps(:,3)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
axes('Position',[0.28,0.68,0.08,0.08])
histogram((samps(:,4)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
axes('Position',[0.36,0.6,0.08,0.08])
histogram((samps(:,5)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
axes('Position',[0.44,0.52,0.08,0.08])
histogram((samps(:,6)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
axes('Position',[0.52,0.44,0.08,0.08])
histogram((samps(:,7)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
axes('Position',[0.6,0.36,0.08,0.08])
histogram((samps(:,8)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
axes('Position',[0.68,0.28,0.08,0.08])
histogram(exp(samps(:,9)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
axes('Position',[0.76,0.2,0.08,0.08])
histogram((samps(:,10)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
axes('Position',[0.84,0.12,0.08,0.08])
histogram(exp(samps(:,11)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
axes('Position',[0.92,0.04,0.08,0.08])
histogram((samps(:,12)),15,'FaceColor','m','EdgeColor','none','FaceAlpha',0.8)
xlabel('$\gamma$','Interpreter','LaTex')
And Walter's right. One of the things that subplot does is clear other axes out of the way for you. That doesn't seem to be a feature in this case.
Related Question