File Exchange

image thumbnail

Correlation Matrix Scatterplot

version (3.36 KB) by John Chow
Produces a correlation matrix scatterplot with least-squared fitted lines.


Updated 05 May 2020

View Version History

View License

This function creates multiple bivariate scatterplots similar to SPSS's Matrix Scatterplot but without duplicate relationships. A linear fitted line, the correlation coefficient and the associated p-value are included in each plot. It is helpful when you want to explore the relationships among several variables.

Cite As

John Chow (2021). Correlation Matrix Scatterplot (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

Wei Sheng Gan

Simple and useful! thanks

John Chow

I have revised the program in respond to the comments by Christian Karcher and Robyn Feiss.

Robyn Feiss

This worked great, but would not plot the fitted lines. I believe it is because I have NaN values in my dataset. Is there anyway to ignore the NaNs when plotting the fitted lines?

Saurav Kumar

Very useful. Thanks for sharing!


Indeed a simple and useful function. Thanks!

Christian Karcher

Some minor adjustments were required to get it working without the statistics toolbox (corrcoef instead of corr, max()-min() instead of range()), but afterwards it produced the desired output. Thanks!

John Chow

@Thomas Have you tried the sample at the top of the codes. I just downloaded the program and processed the sample data and ended up with a figure the same as the cover figure. Note: There should be a '%' before 'orient tall' on line 17.) Feel free to send me your data in XLS for me to try if you are still having problems.

Thomas Morrow

p-value calculation appears incorrect, getting p=0.000 for data with little to no correlation.

p-values for negatively correlated variables (negative coefficient) is always 0.

Thomas Morrow

p-value calculation appears incorrect, getting p=0.000 for data with little to no correlation.

Thomas Morrow

Thomas Morrow

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

Inspired by: tight_subplot(Nh, Nw, gap, marg_h, marg_w)

Community Treasure Hunt

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

Start Hunting!