I have created a correlation matrix in pandas using this code:
corr=data.corr()
I have then saved the correlation heatmap with this code
plt.figure(figsize=(16, 6))
mask = np.triu(np.ones_like(data.corr(), dtype=np.bool))
heatmap = sns.heatmap(data.corr(), mask=mask, vmin=-1, vmax=1, annot=True, cmap='BrBG')
heatmap.set_title('Correlation Heatmap', fontdict={'fontsize':18}, pad=16);
plt.savefig(dataQualityCheck 'correlationHeatmap.png', dpi=300, bbox_inches='tight', font = {'family' : 'normal', 'weight' : 'bold', 'size' : 8})
The heatmap looks like this:
How can I modify (reduce, actually) the font size of the numbers inside the heatmap?
CodePudding user response:
IIUC, there is the parameter annot_kws
that you can pass to sns.heatmap
and define the size in:
heatmap = sns.heatmap(data.corr(), mask=mask, vmin=-1, vmax=1, annot=True, cmap='BrBG',
annot_kws={'size':5}) # replace 5 by any value as needed