I create several bar charts during an optimization run in which i do not know the number of bars beforehand. I want all figures to be of the same size. The plots look quite nice, however, if there is only one bar in the figure, it creates a ugly bar chart. I would like to narrow the bar size in case there is one bar with probability 1 (happens quite often). In the attachment it is clearly visible what i mean.
Plot are created with the following code:
for i = 1:N_Locations
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
figure(4+ceil(i/9))
subplot(3,3,i-9*floor(i/9.01))
Rows = find(OrderSize_Empirical(:,1)==Locali(i));
bar(OrderSize_Empirical(Rows(1):Rows(end),3),'FaceColor', [45/255 0 84/255])
Ordersizes = num2cell(OrderSize_Empirical(Rows(1):Rows(end),2));
set(gca,'xticklabel',Ordersizes);
set(gca,'xtick',1:size(OrderSize_Empirical(Rows(1):Rows(end),2)));
str = strcat('Empirical order sizes at location: ',num2str(Locali(i)));
title(str);
xlabel('Order size')
ylabel('Probability')
end