MATLAB: Reduce the distance between boxplots

MATLABplot

Dear all,
Here are my boxplots that generated from the below script:
figure();
ax = axes();
hold(ax);
for i=1:numel(data)
boxchart(x(i)*ones(size(data{i})), data{i},'MarkerStyle','none', ...
'BoxFaceColor', colors(i,:), ...
'LineWidth', 1, ...
'WhiskerLineStyle', '-','BoxWidth',0.5)
end
set(gca,'xtick',[1.5 3.5 5.5 7.5 9.5 11.5 13.5 15.5 17.5])
I want to reduce the distance between first and second boxes; as well as third and forth; … and 15th and 16th.
In order to have 8 couple boxe beside each other. (each couple have distance with next couple)
please let me know how I can do that. Thanks

Best Answer

Carrying on from the above idea...
data=rand(10,16); % just some random data w/ 16 variables/columns
data2=[];
for i=1:8 % augment nan before/between each pair of two
data2=[data2 nan(10,1) data(:,2*i-1:2*i)];
end
data2=[data2 nan(10,1)]; % add the trailing nan column for balance
boxplot(data2) % and present the boxplot
xticks(2.5:3:26) % matchup ticks
ends up with--
which isn't too bad if say so meself! :)
Dunno what will happen/need to do to use barchart in order to get the coloring, too.