MATLAB Examples

Compare Grouped Data Using Box Plots

Load the Fisher iris sample data. The data contains length and width measurements from the sepals and petals of three species of iris flowers. Store the petal length data for the versicolor irises as s1, and the petal length data for the virginica irises as s2.

load fisheriris
s1 = meas(51:100,3);
s2 = meas(101:150,3);

Create a box plot using the sample data. Include a notch on the plot and label each box with the name of the iris species it represents.

boxplot([s1 s2],'notch','on',...

The notches of the two box plots do not overlap, which indicates that the median petal length of the versicolor and virginica irises are significantly different at the 5% significance level.

The median line in the versicolor plot does not appear to be centered inside the box, which indicates that the sample is slightly skewed. Additionally, the versicolor data contains one outlier value, while the virginica data does not contain any outliers.