image thumbnail

boxplotGroup

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

1.8K Downloads

Updated 27 Apr 2021

View License

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

The lines above will create two groups of three boxplot boxes per group, with space separating the groups. You can control the amount of space between groups and you can add group labels.

See the example file for a variety of formatting options available. Most boxplot properties available in Matlab can be specified in this function, too. However, if you're working with boxplot's grouping variable 'g', use the syntax boxplot(x,g) along with the "Group Appearance" options described in Matlab's boxplot() documentation.

** Version 2.0**
As requested by several users, now you can set the color of boxplots by group or by members within each group (see example file).

Tested in Matlab r2016a, r2018b, and r2021a.

Cite As

Adam Danz (2021). boxplotGroup (https://www.mathworks.com/matlabcentral/fileexchange/74437-boxplotgroup), MATLAB Central File Exchange. Retrieved .

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!