Skip to content

Instantly share code, notes, and snippets.

@anasb
anasb / plot_corr.py
Last active October 20, 2019 21:36
Plot Correlations of Pandas DataFrame
def plot_corr(df, size=10):
'''Function plots a graphical correlation matrix for each pair of columns in the dataframe.
Input:
df: pandas DataFrame
size: vertical and horizontal size of the plot'''
corr = df.corr()
fig, ax = plt.subplots(figsize=(size, size))
cax = ax.matshow(corr)
plt.xticks(range(len(corr.columns)), corr.columns, rotation=90)