boxchart

Draws box plots that summarize the distribution of data.

Category: Graphics > 2-D and 3-D Plots

Syntax

boxchart(ydata)

One box for a vector, or one box per column of a matrix.

boxchart(xgroupdata, ydata)

Groups ydata by the categories in xgroupdata and draws one box per group.

boxchart(___, Name, Value)

Sets properties such as 'Notch' or 'BoxWidth'.

b = boxchart(___)

Also returns the BoxChart object.

Description

Each box spans the first to third quartile with a line at the median. Whiskers reach the most extreme points within 1.5 times the interquartile range, and points beyond that are drawn as outliers. Boxes make it easy to compare the spread of several groups side by side.

Input arguments

ydata
Numeric vector or matrix of data.
xgroupdata
Group labels, one per element of ydata.
'Notch'
'on' draws a notch around the median.

Output arguments

b
The BoxChart object.

Example

Three samples

rng(1)
data = [randn(30, 1), 2 + randn(30, 1), 1 + 2*randn(30, 1)];
boxchart(data)
xticklabels({'A', 'B', 'C'})
ylabel('Value')

In the app, the figure is drawn below the code.

See also

histogram median quantile