Skip to content

Instantly share code, notes, and snippets.

@muhammadanas0716
Created January 20, 2023 15:42
Show Gist options
  • Save muhammadanas0716/27c50bfc3fb87f42ecc67315a206b1ec to your computer and use it in GitHub Desktop.
Save muhammadanas0716/27c50bfc3fb87f42ecc67315a206b1ec to your computer and use it in GitHub Desktop.
Correlogram is used to visually see the correlation metric between all possible pairs of numeric variables in a given dataframe (or 2D array).
# Import the needed libraries
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
# Import Dataset
df = pd.read_csv("https://github.com/selva86/datasets/raw/master/mtcars.csv")
# Plot
plt.figure(figsize=(12,10), dpi= 80)
sns.heatmap(df.corr(), xticklabels=df.corr().columns, yticklabels=df.corr().columns, cmap='RdYlGn', center=0, annot=True)
# Decorations
plt.title('Correlogram of mtcars', fontsize=22)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment