Create box chart (box plot)

`boxchart(`

creates a box chart, or box
plot, for each column of the matrix `ydata`

)`ydata`

. If
`ydata`

is a vector, then `boxchart`

creates a
single box chart.

Each box chart displays the following information: the median, the lower and upper quartiles, any outliers (computed using the interquartile range), and the minimum and maximum values that are not outliers. For more information, see Box Chart (Box Plot).

`boxchart(`

groups the data in the vector `xgroupdata`

,`ydata`

)`ydata`

according to the unique values in
`xgroupdata`

and plots each group of data as a separate box chart.
`xgroupdata`

determines the position of each box chart along the
*x*-axis. `ydata`

must be a vector, and
`xgroupdata`

must have the same length as
`ydata`

.

`boxchart(___,`

specifies additional chart options using one or more name-value pair arguments. For
example, you can compare sample medians using notches by specifying
`Name,Value`

)`'Notch','on'`

. Specify the name-value pair arguments after all other
input arguments. For a list of properties, see BoxChart Properties.

returns a
`b`

= boxchart(___)`BoxChart`

object. Use `b`

to set properties of the
box charts after creating them. For a list of properties, see BoxChart Properties.

You can add two types of data tips to a

`BoxChart`

object: one for each box chart and one for each outlier. A general box chart data tip appears at the nonoutlier maximum value, regardless of where you click on the box chart. The displayed`Num Points`

value includes`NaN`

values in the corresponding`ydata`

, but`boxchart`

discards the`NaN`

values before computing the box chart statistics.You can use the

`datatip`

function to add more data tips to a`BoxChart`

object, but the indexing of data tips differs from other charts.`boxchart`

first assigns indices to the box charts and then assigns indices to the outliers. For example, if a`BoxChart`

object`b`

displays two box charts and one outlier,`datatip(b,'DataIndex',3)`

creates a data tip at the outlier point.