Data Science

Heatmaps for Correlation Matrices

SQL Mastery Team
June 2, 2026
5 min read

Welcome to **Day 132**. If شما have 20 columns, شما can't look at 190 different scatter plots. You use a **Heatmap**.

What is a Correlation Matrix?

It's a table showing how every column correlates with every other column (-1 to 1).

The Code

# 1. Calculate the correlations

corr = df.corr()

# 2. Draw the Heatmap

sns.heatmap(corr, annot=True, cmap='coolwarm')

plt.show()

How to read it

  • **Bright Red (Near 1)**: Strong positive relationship.
  • **Bright Blue (Near -1)**: Strong negative relationship.
  • **Pale colors (Near 0)**: No relationship.
  • This is the fastest way to "Mine" your data for interesting stories to tell your stakeholders.

    Your Task for Today

    Calculate a correlation matrix for a DataFrame and plot it using a heatmap.

    *Day 133: Customizing Figure Size and Layout.*

    Ready to put your knowledge into practice?

    Join SQL Mastery and learn through interactive exercises.