Reputation: 81
I'm having some trouble with my heatmap plot of the correlation. It's not showing all the columns I'm interested in.
This is my code:
sns.set(style="white")
# Compute the correlation matrix
corr = data.corr()
# Generate a mask for the upper triangle
mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(11, 9))
# 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, vmax=1, vmin=-1, center=0,
square=True, linewidths=1, cbar_kws={"shrink": .5})
The code is based on :https://seaborn.pydata.org/examples/many_pairwise_correlations.html
And here is a snip of the data columns missing
The problem, as you can see, is that I'm missing CIVIST_D, F, L and I can´t figure out to fix it.
Kind regards Christian
Upvotes: 8
Views: 10529
Reputation: 159
Try to increase the size of plot. It worked for me
corr=df.corr()
plt.subplots(figsize=(20,15))
sns.heatmap(corr)
Upvotes: 9
Reputation: 4150
Not sure if that helps but make sure that the correlation is indeed computed for your desired columns. For example:
'CIVIST_D' in corr.index
Upvotes: 0