Reputation: 351
I am plotting a correlation heat map using Seaborn. Correlation ranges from 0.6-1. I am using the following code. Trouble I have is I am getting the same color in all the cells. How can I enforce more divergence in color?
mask = np.triu(np.ones_like(corr, dtype=bool))
# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(11, 9))
# Generate a custom diverging colormap
cmap = sns.diverging_palette(20, 220, n=256, as_cmap=True)
# Draw the heatmap with the mask and correct aspect ratio
sns.heatmap(corr,
mask=mask,
cmap=cmap,
vmax=.3,
center=0,
square=True,
linewidths=.5,
annot = True,
fmt='.2f',
annot_kws={'size': 10},
cbar_kws={"shrink": .75})
plt.title('Asset Correlation Matrix')
plt.tight_layout()
ax.tick_params(axis = 'x', labelsize = 8)
ax.set_ylim(len(corr)+1, -1)
Upvotes: 1
Views: 728
Reputation: 141
Try adding the vmin and vmax params for sns.heatmap(...) as outlined here (https://python-graph-gallery.com/92-control-color-in-seaborn-heatmaps/).
Since your values range from 0.6 to 1.0, you can try setting vmin = 0.55 and vmax = 1.0 to limit the color range to those values.
Upvotes: 1