当图的数量少于行x列时,如何将子图对齐到图的中心?

How to align subplots to the centre of the figure when number of plots are less than rowsxcolumns?

当绘图数量少于行x列时,是否可以将子图对齐到图的中心?例如;

如果我使用这个:

figure
for pl=1:5
      subplot(3,2,pl)
end

我得到这个结果: 我能否以某种方式获得以下输出,其中由于最后一行只有一个图,它会如下所示居中对齐?

您可以手动更新使用子图时创建的任何轴的位置,例如

figure
for pl=1:5
   ax(pl) = subplot(3,2,pl)
end
% post r2014b
ax(5).Position(1) = 0.5-ax(5).Position(3)/2;

如果您使用的是 2014b 之前的 matlab,则需要将最后一行更改为以下内容:

% pre r2014b
pos = get ( ax(5), 'position' );
pos(1) = 0.5-pos(3)/2;
set ( ax(5), 'position', pos );