File Exchange

image thumbnail

Correlation Matrix Scatterplot

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

43 Downloads

Updated 05 May 2020

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 (2020). Correlation Matrix Scatterplot (https://www.mathworks.com/matlabcentral/fileexchange/53043-correlation-matrix-scatterplot), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (10)

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?

Very useful. Thanks for sharing!

JCanal

Indeed a simple and useful function. Thanks!

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.

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.

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

Updates

2.0.0.01

(1) Ignore data pairs with NaNs, (2) Sample size added on plots, and (3) No statistics toolbox needed. (May 2020)

2.0.0.0

(1) Ignore data pairs with NaNs, (2) Sample size added on plots, and (3) No statistics toolbox needed. (May 2020)

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

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