MATLAB: How to group boxplots by modifying the X locations

boxplot

Is there a way to set the 'X' coordinates of several boxplots?
For instance something similar to…
X = [1.2 1.8 3.2 3.8 5.2 5.8];
boxplot(X, Y)
so that it would look like groups of boxplots are set closer together?

Best Answer

Perhaps you are looking for the positions option?
X = [1.2 1.8 3.2 3.8 5.2 5.8];
Y = rand(100, 6);
boxplot(Y, 'positions', X, 'labels', X)