Three things I hope to edit on this correlation graph.
- Remove the white space on top. I tried
plt.tight_layout(pad=0)
andplt.gcf().subplots_adjust(wspace=0, hspace=0)
. But both methods failed. - I tried to add ticks by
sns.set_style({'xtick.bottom': True}, {'ytick.left': True})
but strangely it didn't work as shown in screenshot of the graph. - How to limit the correlation coefficients to just two digits?
Below is the whole codes I used.
sns.set(style="white")
corr = by_profit.T.corr()
mask = np.triu(np.ones_like(corr, dtype=np.bool))
f, ax = plt.subplots(figsize=(10, 9),dpi=100)
sns.heatmap(corr, mask=mask, cmap='coolwarm', vmax=1, vmin=-1,center=0,
square=True, linewidths=.5, cbar_kws={"shrink": .5},annot = True,
annot_kws = {"size": 9})
ax.set_xticklabels(c.get_xticklabels(), rotation=45, horizontalalignment='right')
sns.set_style({'xtick.bottom': True}, {'ytick.left': True})
plt.title('Correlation Between Sub-Category Sales')
plt.xlabel('')
plt.ylabel('');