How to Make a Correlogram in StatFas, SPSS, R, Python and Excel
This tutorial draws the same correlogram, hiding non-significant cells after Holm adjustment, in five tools. The example table has ten numeric columns and no group column: il6, tnf, crp, glucose, insulin, hba1c, bmi, waist, fat_pct and age.
What you will make
A publication-ready correlogram with the compulsory checks and statistics that go with it, produced in five ways. The StatFas generator needs no coding and no account to run; the code versions are for readers who want a scripted workflow. For the theory behind the plot and how to read it, see the full guide.
Example data
| Column | Contents |
|---|---|
il6, tnf, crp | Inflammation markers |
glucose, insulin, hba1c | Glycaemic measures |
bmi, waist, fat_pct | Body composition |
age | Age in years |
Save your table as correlogram.csv with a header row. The StatFas generator has a Load Example Data button with simulated data, so you can follow along without your own file. The example data are invented for illustration and are not real findings.
Method 1: StatFas (free, no coding)
- Open the Correlogram Generator and click Load Example Data, or paste/upload your own file.
- Choose the coefficient and the p-value adjustment (Holm is a good default). Set Variable order to clustered to group related variables, and choose how non-significant cells are shown.
- Run the analysis. Read the correlation matrix, 95% confidence intervals, adjusted p-values, descriptive statistics and distribution check.
- Change the colors for negative and positive correlations, fonts, sizes and triangle display styles in the figure controls.
- Log in (free) to download the figure, tables and Word file, including the APA7 correlation table.
Method 2: SPSS
SPSS gives the correlation table but not a correlogram. In the menus: Analyze > Correlate > Bivariate, select the variables, tick Pearson, Spearman or Kendall’s tau-b, and keep Flag significant correlations. Syntax:
CORRELATIONS
/VARIABLES=il6 tnf crp glucose insulin hba1c bmi waist fat_pct age
/PRINT=TWOTAIL NOSIG
/MISSING=PAIRWISE.
NONPAR CORR
/VARIABLES=il6 tnf crp glucose insulin hba1c bmi waist fat_pct age
/PRINT=SPEARMAN TWOTAIL NOSIG
/MISSING=PAIRWISE.SPSS does not adjust for multiple tests and draws no matrix plot. Copy the matrix into Excel for a colour scale, or use StatFas, R or Python.
Method 3: R
library(Hmisc); library(corrplot)
df <- read.csv("correlogram.csv")
rc <- rcorr(as.matrix(df), type = "pearson") # or "spearman"
p_adj <- matrix(0, ncol(df), ncol(df), dimnames = dimnames(rc$P))
p_adj[lower.tri(p_adj)] <- p.adjust(rc$P[lower.tri(rc$P)], method = "holm")
p_adj[upper.tri(p_adj)] <- t(p_adj)[upper.tri(p_adj)]
corrplot(rc$r, method = "circle", type = "lower", order = "hclust",
p.mat = p_adj, sig.level = 0.05, insig = "blank", tl.col = "black")Packages: install.packages(c("Hmisc","corrplot")). Use method = "square" or "number" for other displays.
Method 4: Python
import numpy as np, pandas as pd, seaborn as sns, matplotlib.pyplot as plt
from scipy import stats
df = pd.read_csv("correlogram.csv"); cols = df.columns; k = len(cols)
r = df.corr(method="pearson") # use "spearman" or "kendall" for skewed data
pm = pd.DataFrame(np.ones((k, k)), index=cols, columns=cols); pairs = []
for i in range(k):
for j in range(i + 1, k):
pairs.append((i, j, stats.pearsonr(df.iloc[:, i], df.iloc[:, j])[1]))
p = np.array([q[2] for q in pairs]); order = p.argsort(); m = len(p); adj = np.empty(m); run = 0
for rank, idx in enumerate(order): # Holm adjustment
run = max(run, min(1, (m - rank) * p[idx])); adj[idx] = run
for (i, j, _), a in zip(pairs, adj): pm.iloc[i, j] = pm.iloc[j, i] = a
mask = np.triu(np.ones((k, k), bool)) | (pm.values >= 0.05) # hide upper triangle and non-significant cells
ax = sns.heatmap(r, mask=mask, cmap="RdBu_r", vmin=-1, vmax=1, annot=True, fmt=".2f", square=True, cbar_kws={"label": "Pearson r"})
plt.tight_layout(); plt.savefig("correlogram.png", dpi=300)
print(r.round(2)); print("Pairs significant after Holm:", int((adj < 0.05).sum()), "of", m)Requires numpy, pandas, scipy, seaborn and matplotlib. Use method="spearman" in df.corr and stats.spearmanr for rank correlations.
Method 5: MATLAB, OriginPro, Excel and others
Excel
Compute the matrix with Data > Data Analysis > Correlation (enable the Analysis ToolPak), then select the matrix and apply Home > Conditional Formatting > Color Scales with blue–white–red. Excel gives no p-values or adjustment.
MATLAB
T = readtable("correlogram.csv");
[R, P] = corrcoef(T{:,:});
heatmap(T.Properties.VariableNames, T.Properties.VariableNames, R, "Colormap", redbluecmap);Which method should you choose?
| Tool | Cost and skill | Plot | Statistical checks | Report-ready output |
|---|---|---|---|---|
| StatFas | Free, in the browser | Yes (circles, squares, numbers) | Pearson/Spearman/Kendall, CIs, Holm/FDR | Yes, APA7 table in Word |
| SPSS | Licence needed | No | Coefficients and p-values, no adjustment | Tables only |
| R | Free, coding | Yes (corrplot) | Hmisc, p.adjust | Manual |
| Python | Free, coding | Yes (seaborn) | scipy, manual adjustment | Manual |
Choose StatFas for speed and APA7-ready output, SPSS if your department already licenses it and you only need the statistics, and R or Python when the analysis must be scripted and reproduced in a pipeline.
How to report the result in APA7
Present a table with correlations, means and standard deviations, and a note stating the coefficient, the correction and the significance level. In the text, report r(df), 95% CI and the adjusted p for key pairs. StatFas writes the APA7 table and paragraph for you.
See the guide for an example paragraph.
Troubleshooting
- Almost everything is significant. With large n even tiny correlations are significant. Focus on effect size and confidence intervals.
- Different n in each cell. Pairwise deletion was used. Report the range of n or use complete cases.
- A correlation looks strong but the scatterplot is odd. Outliers or curvature can mislead Pearson. Plot the pair or use Spearman.
- Colours are hard to read in print. Use the colour-blind safe palette or grey scale in the figure style panel.
Frequently asked questions
Can SPSS make a correlogram?
Not directly. SPSS provides the correlation table; use Excel conditional formatting, R, Python or StatFas for the plot.
How many variables can a correlogram handle?
Up to about 30 stay readable. Beyond that, order by clustering or show only the strongest correlations.
Related tools, guides and tutorials
- Guide: Correlogram Explained: How to Make, Read and Report a Correlation Matrix Plot
- Correlation calculator
- Pearson correlation calculator
- Spearman’s rank correlation calculator
- Kendall’s tau correlation calculator
- Heatmap maker
- Mantel network analysis
- Correlation tutorial
- Heatmap tutorial
- Pearson, Spearman and Kendall explained
- Bonferroni correction explained
- Normality tests explained
- PCA Biplot Generator
- Parallel Coordinates Plot Generator
- 3D Scatter Plot Generator
- All tutorials
- All blog posts
References
- American Psychological Association. (2020). Publication manual of the American Psychological Association (7th ed.).
- Benjamini, Y., & Hochberg, Y. (1995). Controlling the false discovery rate: A practical and powerful approach to multiple testing. Journal of the Royal Statistical Society B, 57(1), 289–300.
- Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum Associates.
- Friendly, M. (2002). Corrgrams: Exploratory displays for correlation matrices. The American Statistician, 56(4), 316–324.
- Holm, S. (1979). A simple sequentially rejective multiple test procedure. Scandinavian Journal of Statistics, 6(2), 65–70.