Grouping boxlot matlab

I have x = rand (1000,6); y = Rand (1000.6); D (:, 1: 2: 12) = x; D (:, 2: 2: 12) = y;

I would like to build a grouped boxplot , where x (:, i) and y (:, i) are grouped squares (or pairs of factors). But it does not seem to be able to determine how to specify the groupings.

In this way:

 figure('color',[1,1,1]); boxplot(D,'factorgap',10,'color','rk') axis([0 25 -1 5]) set(gca,'xtick',1.8:4.3:50) set(gca,'ytick',0:10) set(gca,'xticklabel',{'Direct care','Housekeeping','Mealtimes','Medication','Miscellaneous','Personal care'}) ylabel('Normalised Y'); legend(findobj(gca,'Tag','Box'),'HBN04-01 multibed','YAB single ') 

enter image description here

But it looks a little untidy, how can I get the gaps between the pairs of drawers more?

+4
source share
1 answer

You need a double grouping variable:

 boxplot(D, {reshape(repmat('A':'F',2,1),12,1) repmat((1:2)',6,1)} ,'factorgap',10,'color','rk') 

Centering shortcuts is pretty impractical and overnight.

+3
source

All Articles