分组箱图Matlab [英] Grouping boxplot matlab
本文介绍了分组箱图Matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有x = rand(1000,6); y = rand(1000,6); D(:,1:2:12)= x; D(:,2:2:12)= y;
I have x=rand(1000,6); y=rand(1000,6); D(:,1:2:12)=x; D(:,2:2:12)=y;
我想绘制一个分组的boxplot
,其中x(:,i)和y(:,i)是分组的箱线图(或因子对).但似乎无法找出如何指定分组.
I would like to plot a grouped boxplot
where x(:,i) and y(:,i) are grouped boxplots (or factor pairs). But can't seem to work out how to specify the groupings.
因此:
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 ')
但是看起来有点不整洁,如何使成对的箱形图之间的间隙更大?
But it looks a bit untidy, how do I get the gaps between pairs of boxplots larger?
推荐答案
您需要一个双重分组变量:
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 the labels is quite impractical and nightmerish.
这篇关于分组箱图Matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文