Categories &

Functions List

Function Reference: boxchart

statistics: boxchart (ydata)

statistics: boxchart (xgroupdata, ydata)

statistics: boxchart (…, 'GroupByColor', cgroupdata)

statistics: boxchart (tbl, yvar)

statistics: boxchart (tbl, xvar, yvar)

statistics: boxchart (…, name, value)

statistics: boxchart (ax, …)

statistics: b = boxchart (…)

Draw a box chart.

boxchart (ydata) draws one box over the observations in ydata. The box spans the lower and upper quartiles with the median across it, the whiskers reach the furthest observations within one and a half interquartile ranges of the box, and whatever lies beyond is drawn as a marker.

boxchart (xgroupdata, ydata) draws one box per distinct value of xgroupdata, which holds one value per observation.

boxchart (tbl, yvar) and boxchart (tbl, xvar, yvar) take the observations, and where asked the grouping, from the named columns of a table. The chart keeps the table, so assigning SourceTable again re-reads it.

b = boxchart (…) returns the stats.chart.BoxChart object drawn, whose properties may be set afterwards to redraw it; see stats.chart.BoxChart. Where 'GroupByColor' names a grouping, one object is returned per colour group, in the order of its distinct values.

'GroupByColor' cannot be given with a table, which MATLAB R2026a refuses as well.

Every other name-value pair sets the property of that name on the object; see stats.chart.BoxChart for what each takes.

See also: stats.chart.BoxChart, boxplot, swarmchart

Source Code: boxchart

One box over a sample: the box spans the quartiles with the median across it, the whiskers reach the furthest values within one and a half interquartile ranges, and the rest are drawn as markers.

 load fisheriris
 boxchart (meas(:,1));
 ylabel ('sepal length');
plotted figure

One box per group, and a notch about each median. Two notches that do not overlap mark medians that differ at roughly the five per cent level.

 load fisheriris
 g = grp2idx (species);
 boxchart (g, meas(:,1), 'Notch', 'on');
 xlabel ('species');
 ylabel ('sepal length');
plotted figure

The chart keeps what it was drawn from, so its properties may be set afterwards and it redraws itself.

 load fisheriris
 b = boxchart (meas(:,1));
 b.Orientation = 'horizontal';
 b.BoxFaceColor = [0.85, 0.325, 0.098];
 b.JitterOutliers = 'on';
plotted figure