Alternative box plot
Editor's Note: This file was selected as MATLAB Central Pick of the Week
NOTE: this function is now available from the IoSR Matlab Toolbox as iosr.statistics.boxPlot.
-------------------------
Alternative box plot function for Matlab with many options. These options include:
- Variable sample sizes (via the tab2box() function).
- Show box sample size.
- Scaled or uniform box spacing.
- Box width scaled by sample size.
- Overlay scatter plots of underlying data.
- Overlay the mean of the data.
- Overlay additional percentiles, and attach labels to them.
- Hierarchical X-labeling and support for multidimensional data.
- Notched boxes.
- Vertical lines to separate groups.
- Automated construction of a legend.
- Set box limits as percentiles.
- Set whisker extent via various methods.
- Use of weighted quantiles.
- Creation of violin plots.
Cite As
Christopher Hummersone (2024). Alternative box plot (https://github.com/IoSR-Surrey/MatlabToolbox), GitHub. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- AI and Statistics > Statistics and Machine Learning Toolbox > Descriptive Statistics and Visualization > Statistical Visualization > Box Plots >
Tags
Acknowledgements
Inspired by: notBoxPlot, Hierarchically grouped boxplot
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
+iosr
+iosr/+acoustics
+iosr/+auditory
+iosr/+bss
+iosr/+dsp
+iosr/+figures
+iosr/+general
+iosr/+statistics
+iosr/+svn
Versions that use the GitHub default branch cannot be downloaded
Version | Published | Release Notes | |
---|---|---|---|
3.2.1.0 | Updated version number.
|
|
|
3.1.1.0 | Added percentile options for box and whisker extent. Modified help to clarify scatter plotting.
|
|
|
3.1.0.0 | Added 'theme' property to allow multiple display properties to be changed simultaneously. Various bug fixes. |
||
3.0.2.0 | More bug fixes. Forced legend alpha to match box alpha. |
||
3.0.1.0 | Added ability to specify colors as a colormap function. Changed some size properties to no longer be specifiable for each group. Bug fixes. |
||
3.0.0.0 | Re-implemented function as a class (with a new name). Added property to automate construction of a legend. |
||
2.0.8.0 | Added meanSize property. |
||
2.0.7.0 | Corrected calculation of mean when data include NaN. Updated picture. |
||
2.0.6.0 | Added options for displaying the means. |
||
2.0.5.0 | Added trap for MarkerEdgeAlpha (scatterAlpha), which older versions of Matlab do not support. |
||
2.0.4.0 | Added layer and transparency options. |
||
2.0.3.0 | Fixed automatic placement of boxes. |
||
2.0.2.0 | Corrected bug where x offset was erroneous if y was not hierarchical. |
||
2.0.1.0 | Small tweaks to improve robustness. |
||
2.0.0.0 | Numerous changes to interface in order to support multidimensional data and improve hierarchical data labelling. Added scaleWidth option to scale box widths according to sample size. |
||
1.6.3.0 | Added x-shaping to outliers and tweaked offset distribution. |
||
1.6.2.0 | Added x shaping for overlayed scatter plots whereby the random x offset is related to the data distribution. Fixed bug whereby xSeparator handle would be sought even if xSeparator was not specified. |
||
1.6.1.0 | Shuffled a few things around so that the creation order defines the layering, rather than relying on uistack(). Added linkprop() and listener to keep axes in sync and to change xseparator if ylim changes. |
||
1.6.0.0 | Added options to: overlay a scatter plot of the underlying data, display the sample size in each box, add x-group separators, and add hierarchical labelling. Shuffled outputs slightly. Thanks to Arnold for the suggestions.
|
||
1.5.1.0 | Fixed bug where x is a cell array of strings. |
||
1.5.0.0 | Remove NaN from x data (and corresponding y data). |
||
1.4.1.0 | Updated documentation. |
||
1.4.0.0 | Improved robustness to small or empty samples. Add tab2box function for arranging tabular into the format accepted by box_plot. |
||
1.3.0.0 | Function now natively supports sub-groups, handles NaNs more robustly, and returns sample size(s). A few other minor tweaks and doc changes. |
||
1.2.0.0 | Moved quantile calculation to new function. |
||
1.1.0.0 | Changed/corrected quantile estimation algorithm. Details in help text. |
||
1.0.0.0 |