Matlab中有關boxplot(X)命令的解釋:
boxplot(X) produces a box and whisker plot for each column of the matrix X. The box has lines at the lower quartile, median, and upper quartile values. Whiskers extend from each end of the box to the adjacent values in the data—by default, the most extreme values within 1.5 times the interquartile range from the ends of the box. Outliers are data with values beyond the ends of the whiskers. Outliers are displayed with a red + sign.
格式 boxplot(X) %產生矩陣X的每一列的盒圖和“須”圖,“須”是從盒的尾部延伸出來,并表示盒外數據長度的線,如果“須”的外面沒有數據,則在“須”的底部有一個點。
boxplot(X,notch) %當notch=1時,產生一凹盒圖,notch=0時產生一矩箱圖。
boxplot(X,notch,'sym') %sym表示圖形符號,默認值為“+”。
boxplot(X,notch,'sym',vert) %當vert=0時,生成水平盒圖,vert=1時,生成豎直盒圖(默認值vert=1)。
boxplot(X,notch,'sym',vert,whis) %whis定義“須”圖的長度,默認值為1.5,若whis=0則boxplot函數通過繪制sym符號圖來顯示盒外的所有數據值。
Examples 1
The following commands create a box plot of car mileage grouped by country.
load carsmall
boxplot(MPG,Origin)
Examples 2
The following example produces notched box plots for two groups of sample data.
x1 = normrnd(5,1,100,1);
x2 = normrnd(6,1,100,1);
boxplot([x1,x2],'notch','on')
Examples 3
x1 = normrnd(5,1,100,1);
x2 = normrnd(6,1,100,1);
boxplot([x1,x2])
The difference between the medians of the two groups is approximately 1.Since the notches in the boxplot do not overlap, you can conclude, with 95% confidence, that the true medians do differ.
Examples 4
The following figure shows the boxplot for same data with the length of the whiskers specified as 1.0 times the interquartile range. Points beyond the whiskers are displayed using +.
x1 = normrnd(5,1,100,1); x2 = normrnd(6,1,100,1); boxplot([x1,x2],'notch','on','whisker',1)