Statistical Significance
Version 1.0.0 (4 KB) by
Omer Yuval
Add statistical significance lines and asterisks to an existing plot
This script gets an axis handle and a 4D matrix (stats) and plots significance lines and asterisks on top.
Significance lines and asterisks are added only for pairs assigned with a positive value (the number of asterisks) in stats. For non-integer values, the p-value is displayed instead.
To set the stats matrix, simply initialize a 4D matrix with the first two dimensions corresponding to categories, and the last two dimensions to groups (see the examples file).
Then, assign the number of asterisks (or p-value) to the relevant pairs. For example:
stats = zeros(5,5,4,4); % Initialize the stats matrix for 5 categories and 4 groups.
stats(1,3,1,2) = 2; % Add a significance line and two asterisks between the bar of category 1, group 1, and the bar of category 3, group 2.
This script takes into account error bars when adding significance lines, and can also deal with bar plots generated using the 'hist' parameter (see example 2).
Cite As
Omer Yuval (2024). Statistical Significance (https://www.mathworks.com/matlabcentral/fileexchange/92613-statistical-significance), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2020b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
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.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0 |