Bonjour, pour commencer à utiliser Crook connecte toi !

Easy to read correlation heat map

pre-formated, colored, easy to read


import matplotlib.pyplot as plt import numpy as np import seaborn as sns

corr = df.corr()

Generate a mask for the upper triangle which is duplicate value

mask = np.triu(np.ones_like(corr, dtype=np.bool))

Set up the matplotlib figure size

f, ax = plt.subplots(figsize=(11, 9)) sns.set_style(style = 'darkgrid')

Generate a custom diverging colormap

cmap = sns.diverging_palette(220, 10, as_cmap=True)

Draw the heatmap with the mask and correct aspect ratio

sns.heatmap(corr, mask=mask, cmap=cmap, annot = True, vmax=.3, center=0, square=True, linewidths=.5, cbar_kws={"shrink": .5}) plt.title('correlation heatmap') plt.show()

 

À propos
logo
image de profil

Rolls