www.gusucode.com > stats 源码程序 matlab案例代码 > stats/CreateBoxPlotsForGroupedDataExample.m

    %% Create Box Plots for Grouped Data
%

%%
% Load the sample data.
load carsmall

%%
% Create a box plot of the miles per gallon (|MPG|) measurements from the 
% sample data, grouped by the vehicles' country of origin (|Origin|). Add a
% title and label the axes.
boxplot(MPG,Origin)
title('Miles per Gallon by Vehicle Origin')
xlabel('Country of Origin')
ylabel('Miles per Gallon (MPG)')

%%
% Each box visually represents the MPG data for cars from the specified
% country. Italy's "box" appears as a single line because the sample data
% contains only one observation for this group.