File Exchange

image thumbnail


version 1.2.2 (4.08 KB) by Adam Danz
Group boxplots together along the x-axis with space between groups.


Updated 09 Mar 2020

View License

x = {rand(100,2), rand(20, 2), rand(150,2)};

The lines above will create two groups of three boxplot boxes per group, with space separating the groups.

You can specify the amount of space between groups, the primary labels under each box, and the secondary labels that identify the groups. Group labels can be horizontal, under the x-axis, or vertical, between groups.

Other boxplot properties can be passed to Matlab's boxplot function as well.

NOTE: If you're working with a grouping variable 'g', use the syntax boxplot(x,g) along with the "Group Appearance" options described in Matlab's boxplot() documentation.

Also see Kelly Kearney's boxplot2()

Cite As

Adam Danz (2020). boxplotGroup (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)


Easy to use if want to plot multiple boxplot together, especially for writing a paper



Instead of creating a new axis when an axis handle is not provided, the current axis will be used via gca().


Suppress linkprops() and changes to toolbar suppression to work with versions prior to r2018b.


When 2nd axis is added, main axis is set to current axis.


Using linkprop and listener to resize axis2 when main axis is resized; axis handle provided in boxplot(); added DeleteFct to main axis; removed toolbar for axis2; other minor changes.

MATLAB Release Compatibility
Created with R2019b
Compatible with any release
Platform Compatibility
Windows macOS Linux