本博文源于matlab统计图的绘制,学到就是赚到。特别实用。

boxplot函数

boxplot(x)
boxplot(x, notch)
boxplot(x,notch, 'sym')
boxplot(x,notch,'sym',vert)
boxplot(x,notch, 'sym',vert,whis)
  • x是分析样本
  • notch=1 凹口盒装图,notch =0 矩形盒装图
  • sym 是绘图符号
  • vert=0 得到水平盒装图 1是得到垂直盒装图

例子:随机生成样本,绘制样本凹口盒装图和矩形盒装图

实验代码:

>> N = 1024;
>> x1 = normrnd(5,1,N,1); %生成mu=5,sigma=1,N*1服从正态分布的矩阵 
>> x2 = normrnd(6,1,N,1); 
>> x = [x1 x2];
>> figure(1)
>> syml='*';
>> notch1=1; % 凹口
>> boxplot(x,notch,syml);
??? Undefined function or variable 'notch'.

>> boxplot(x,notch1,syml);
>> figure(2)
>> notch2 = 0;

>> boxplot(x,notch2);%矩形盒装图

实验效果及讲解

在这里插入图片描述
左边图垂直带凹口的盒装图,右边垂直矩形的盒装图

  • 盒的上下边界线分别对应样本的第25个和第75个百分点处。
  • 盒中间的直线是样本的中值,如果中值不在盒的中间,表明存在倾斜度。
  • 盒的凹口是样本中值置信区间的图形化表示。

更多推荐