1import matplotlib.pyplot as plt
2import seaborn as sns
3figure = plt.figure(figsize=(12, 6))
4sns.heatmap(train_data.corr(), annot=True,cmap=plt.cm.cool)
5plt.tight_layout()
6plt.xlabel('Corr')
7plt.show()
1import seaborn as sns
2%matplotlib inline
3
4# calculate the correlation matrix
5corr = auto_df.corr()
6
7# plot the heatmap
8sns.heatmap(corr,
9 xticklabels=corr.columns,
10 yticklabels=corr.columns)
11
1from string import ascii_letters
2import numpy as np
3import pandas as pd
4import seaborn as sns
5import matplotlib.pyplot as plt
6
7sns.set_theme(style="white")
8
9d = pd.read_csv("../path_to/csv_name.csv")
10# Compute the correlation matrix
11corr = d.corr()
12
13# Generate a mask for the upper triangle: triu means upper triangle
14mask = np.triu(np.ones_like(corr, dtype=bool))
15
16# Set up the matplotlib figure
17f, ax = plt.subplots(figsize=(11, 9))
18
19# Generate a custom diverging colormap
20cmap = sns.diverging_palette(230, 20, as_cmap=True)
21
22# Draw the heatmap with the mask and correct aspect ratio
23sns.heatmap(corr, mask=mask, cmap=cmap, vmax=.3, center=0,
24 square=True, linewidths=.5, cbar_kws={"shrink": .5})