Main Content

Visualize summary statistics with box plot

`boxplot(`

creates a box plot of the data in
`x`

)`x`

. If `x`

is a vector,
`boxplot`

plots one box. If `x`

is a
matrix, `boxplot`

plots one box for each column of
`x`

.

On each box, the
central mark indicates the median, and the bottom and top edges of the box indicate the 25th and
75th percentiles, respectively. The whiskers extend to the most extreme data points not
considered outliers, and the outliers are plotted individually using the `'+'`

marker symbol.

`boxplot(`

creates
a box plot using the axes specified by the axes graphic object `ax`

,___)`ax`

,
using any of the previous syntaxes.

`boxplot(___,`

creates
a box plot with additional options specified by one or more `Name,Value`

)`Name,Value`

pair
arguments. For example, you can specify the box style or order.

`boxplot`

creates a visual representation of the data, but does not return numeric values. To calculate the relevant summary statistics for the sample data, use the following functions:`min`

— Find the minimum value in the sample data.`max`

— Find the maximum value in the sample data.`median`

— Find the median value in the sample data.`quantile`

— Find the quantile values in the sample data. For example, to compute the 25th and 75th percentiles of`x`

, specify`quantile(x,[0.25 0.75])`

. For more information on how the percentiles are computed, see Algorithms.`iqr`

— Find the interquartile range in the sample data.`grpstats`

— Calculate summary statistics for the sample data, organized by group.

You can see data values and group names using the data cursor in the figure window. The cursor shows the original values of any points affected by the

`datalim`

parameter. You can label the group to which an outlier belongs using the`gname`

function.To modify graphics properties of a box plot component, use

`findobj`

with the`Tag`

property to find the component's handle.`Tag`

values for box plot components depend on parameter settings, and are listed in the following table.Parameter Settings Tag Values All settings `'Box'`

`'Outliers'`

When `'PlotStyle'`

is`'traditional'`

`'Median'`

`'Upper Whisker'`

`'Lower Whisker'`

`'Upper Adjacent Value'`

`'Lower Adjacent Value'`

When `'PlotStyle'`

is`'compact'`

`'Whisker'`

`'MedianOuter'`

`'MedianInner'`

When `'Notch'`

is`'marker'`

`'NotchLo'`

`'NotchHi'`

You can also create a `BoxChart`

object by using the `boxchart`

function. Although `boxchart`

does not include all the functionality
of `boxplot`

, it has some advantages. Unlike
`boxplot`

, the `boxchart`

function:

Allows for categorical rulers along the group axis

Provides the option of a legend

Works well with the

`hold on`

commandHas an improved visual design that helps you see notches more easily

To control the appearance and behavior of the object, change the BoxChart Properties.

[1] McGill, R., J. W. Tukey, and W. A. Larsen.
“Variations of Boxplots.” *The American Statistician*.
Vol. 32, No. 1, 1978, pp. 12–16.

[2] Velleman, P.F., and D.C. Hoaglin. *Applications,
Basics, and Computing of Exploratory Data Analysis*. Pacific
Grove, CA: Duxbury Press, 1981.

[3] Nelson, L. S. “Evaluating Overlapping
Confidence Intervals.” *Journal of Quality Technology*.
Vol. 21, 1989, pp. 140–141.

[4] Langford, E. “Quartiles in Elementary Statistics”, *Journal
of Statistics Education*. Vol. 14, No. 3, 2006.

`anova1`

| `kruskalwallis`

| `multcompare`

| `min`

| `max`

| `median`

| `quantile`

| `grpstats`