Before the painting, first introduce
Matlab BoxPlot,The following description is from http://www.plob.org/2012/06/10/2153.html
Because Matlab has the powerful computation function, with its statistical data function advantage is obvious, here to share uses the MATLAB BoxPlot some skill, for everybody reference.
Matlab BoxPlot
Command
The format is as follows
BoxPlot (X) : A box diagram and a "whisker" diagram for each column of the Matrix X, a line extending from the end of the box and representing the length of the outside of the box, if there is no data outside the "must", there is a point at the bottom of the "must". www.iLoveMatlab.cn
BoxPlot (X,notch) : When notch=1, produces a concave box diagram, notch=0 When a moment box is generated.
BoxPlot (X,notch, ' sym ') :sym represents a graphical symbol with a default value of "+".
BoxPlot (X,notch, ' sym ', vert) % when vert=0, generate a horizontal box diagram, vert=1, generate a vertical box graph (default vert=1). MATLAB Chinese Forum
BoxPlot (X,notch, ' sym ', vert,whis) %whis defines the length of the "must" graph, the default value is 1.5, and if whis=0 the BoxPlot function shows all data values outside the box by drawing a sym symbol graph.
The box plot (BoxPlot), also known as the box plot (Box-whisker plot), is a method of describing data using the five statistics in the data: minimum, 14th, median, 34th, and maximum, and it can be roughly seen whether the data is symmetrical, Distribution of information, such as the degree of dispersion, especially can be used to compare several samples.
Drawing steps:
1, draw the axis, measure unit size and Data batch unit consistent, starting point is slightly smaller than the minimum value, the length is slightly longer than the total distance of the data batch.
2, draw a rectangular box, the location of the two ends of the data batch corresponding to the upper and lower four sub-number (Q1 and Q3). Draw a line segment to the median (Xm) position inside the rectangular box.
3, in the Q3+1.5IQR (four-bit distance) and Q1-1.5IQR draw two lines with the same line, the two line segment is the outlier truncation point, which is called an internal limit, in F+3iqr and F-3IQR, draw two line segments, called the outer limit. The data represented by a point outside the inner limit is an outlier, where the outliers between the inside and outside limits are mild outliers (mild outliers) and extreme outliers other than outside limits (extreme outliers).
4. Draw a segment from each end of the rectangular box until it is not the farthest point of the outliers, indicating the distribution interval of the normal value of the batch data.
5. Use "0" to mark mild outliers, and "*" to mark Extreme outliers. Data points of the same value are listed in the same data
Line position, the data points of different values are labeled on different data line locations. The box plot of this batch of data is plotted. The box plots plotted by statistical software are generally not marked with an internal limit or an outer limit. :
Example 1:
clearx1=[1,2,2,3,5,3];x2=[2,5,4,5,8,6];g1={x1,x2};%group2x3=[2,8,9,2,1,6];x4=[5,4,3,22,11,6];g2={x3,x4};% GROUP3X5=[10,12,22,4];X6=[12,15,4,25];G3={X5,X6}; G=cat (1,G1,G2,G3); Class={1,2,3}positions = [1 1.25 2 2.25 3 3.25];boxplot (G,class, ' positions ', positions); set (GCA, ' XTick ', [Mean ( Positions (1:2)) mean (positions (3:4)) mean (positions (5:6))]) set (GCA, ' Xticklabel ', {' Group1 ', ' Group2 ', ' Group3 '}) color = [' C ', ' Y ', ' C ', ' y '];h = findobj (GCA, ' Tag ', ' Box '); for J=1:length (h) patch (Get (H (j), ' XData '), Get (H (j), ' Ydata '), Color (j), ' Facealpha ',. 5); Endc = Get (GCA, ' Children '); HLEG1 = Legend (c (1:2), ' Feature1 ', ' Feature2 ');
Example 2:
Data: Boxplotdata.mat, containing two variables of x4058_300 and x4058_400 data
x4058_300=[0.6010 0.6847 0.6798 0.6700 0.6059 0.6749 0.6453 0.6502 0.6847 0.6700 0.5813 0.6404 0.6749 0.6749 0.6650 0.6502 0.6749 0.6305 0.6355 0.7143; 0.6207 0.6650 0.6847 0.6749 0.5961 0.6601 0.6404 0.6700 0.6946 0.6897 0.6059 0.6749 0.6650 0.6749 0.6453 0.6502 0.6700 0.6 256 0.6256 0.6995; 0.6601 0.6700 0.7340 0.7044 0.6355 0.7241 0.6798 0.6897 0.7094 0.6946 0.6256 0.6798 0.7044 0.7389 0.670 0 0.6749 0.7143 0.6650 0.6059 0.6502; 0.7291 0.6108 0.7192 0.7537 0.5862 0.6355 0.6010 0.7143 0.6946 0.6897 0.6453 0.7685 0.7635 0.6404 0.7094 0.7143 0.6108 0.6 552 0.7389 0.6897;0.7044 0.7044 0.7044 0.6847 0.7143 0.6700 0.6650 0.7438 0.7143 0.7143 0.6601 0.6502 0.6995 0.7586 0.7488 0.6897 0.6700 0.6946 0.6897 0.6897; 0.6355 0.6847 0.7291 0.7143 0.6700 0.7438 0.6700 0.6650 0.7192 0.7044 0.6355 0.6847 0.6749 0.7094 0.6798 0.6453 0.7241 0.6 946 0.6108 0.6700] x4058_400 =[0.5922 0.6408 0.6408 0.5825 0.6505 0.6796 0.6214 0.6796 0.6311 0.6505 0.5825 0.6699 0.6602 0.6602 0.7282 0.6602 0.6699 0.7087 0.6505 0.6505; 0.6117 0.6311 0.6602 0.6117 0.6505 0.6796 0.6214 0.6990 0.6990 0.6311 0.5922 0.6796 0.6699 0.6408 0.7184 0.6505 0.6602 0.7087 0.6214 0.6796; 0.6311 0.7184 0.7573 0.6893 0.6311 0.6990 0.6408 0.7087 0.7379 0.6990 0.6699 0.7184 0.6699 0.6699 0.7184 0.6893 0.6699 0.6 990 0.6214 0.6990; 0.6602 0.6311 0.7379 0.6408 0.5922 0.7282 0.5728 0.7087 0.7379 0.7379 0.5728 0.7767 0.7476 0.6214 0.7476 0.6214 0.7379 0.6 893 0.6019 0.6699; 0.6214 0.7476 0.6311 0.6699 0.6699 0.6311 0.6214 0.6699 0.6796 0.6505 0.5922 0.6796 0.7184 0.6893 0.805 8 0.6699 0.6602 0.7184 0.6796 0.6796; 0.6117 0.6893 0.7282 0.6602 0.7573 0.7379 0.6408 0.7184 0.7087 0.7087 0.6990 0.6796 0.6214 0.6311 0.7573 0.6602 0.7379 0.6796 0.6796 0.7282;]
MATLAB Program:
Clearload boxplotdatax01=x4058_300;x02=x4058_400;x1 = [x01 (1,:); x02 (1,:)] '; x2 = [x01 (2,:); x02 (2,:)] '; x3 = [X01 (3,:); X02 (3,:)] '; x4 = [x01 (4,:); x02 (4,:)] '; x5 = [x01 (5,:); x02 (5,:)] '; x6 = [x01 (6,:); x02 (6,:)] '; f=figure (1) x = [x1;x2;x3;x4; X5;X6]; x = x (:); g1 = [Ones (Size (x1)); 2*ones (Size (x2)); 3*ones (Size (x3)); 4*ones (Size (x4)); 5*ones (Size (X5)); 6*ones (Size (x6));]; G1 = G1 (:); g2 = Repmat (1:2,120,1); g2 = G2 (:);p ositions = [[1:6],[7:12]];bh=boxplot] (x, {g2,g1}, ' Notch ', ' on ', ' whisker ', 1, ' Colorgroup ', G1, ' Factorgap ', [8 1], ' symbol ', '. ', ' outliersize ', 4, ' widths ', 0.6, ' positions ', positions ' Xlabel (' Training data size '); Ylabel (' Mean zero-one error ') grid onset (GCA, ' Ylim ', [0.45,0.85], ' gridlinestyle ', '-. '); Set (BH, ' linewidth ', 1.2); color = [' C ', ' Y ', ' g ', ' B ', ' O ', ' B ', ' C ', ' Y ', ' g ', ' B ', ' O ', ' b '];h = Findobj (GCA, ' Tag ', ' Box '); mk= Findobj (GCA, ' tag ', ' Outliers '); % Get handles for outlier Lines.set (MK, ' Marker ', ' o '); % change symbols to all the groups. For J=1:length (h)/2 Patch (Get (H (j), ' XData '), Get (H (j), ' ydata '), Color (4), ' Facealpha ', 0.01*j); End for j= (length (h)/2+1): Length (h) Patch (Get (H (j), ' XData '), Get (H (j), ' Ydata '), Color (4), ' Facealpha ', 0.01* (j-length (h)/2)); Endset (GCA, ' XTick ', [7.5])% set (GCA, ' XTick ', []), set (GCA, ' Xticklabel ', {'})% Create textboxannotation (f, ' TextBox ', ... [0.3 0.075 0.035 0.075],... ' String ', {' * '},... ' Fitboxtotext ', ' off ',... ' Edgecolor ', ' none ');% Create textboxannotation (f, ' textbox ',... [0.7 0.075 0.035 0.075],... ' String ', ',... ' ' Fitboxtotext ', ' off ',... ' Edgecolor ', ' none ');
Matlab BoxPlot for multiple Groups (box-line diagram for multiple sets of data)