I've created a heatmap using Seaborn. I have a dataframe 'all_data_2018' and the below code creates a matrix that looks nearly exactly how I want it to.
fig, ax = plt.subplots(figsize=(20,10))
title = 'Correlation Heatmap'
plt.title(title,fontsize=22)
ttl = ax.title
ttl.set_position([0.5,1.05])
ax.set_xticks([])
ax.set_yticks([])
sns.heatmap(all_data_2018.corr(),annot=True,fmt='.1f',cmap='RdYlGn',linewidths=0.2,ax=ax)
plt.show()
The issue I'm having is that the labels are series ids and I'd prefer them to be the labels. I have a dictionary:
my_dict = {'TM.VAL.INSF.ZS.WT':'insfs','SP.POP.TOTL.FE.ZS':'fempop', 'SP.DYN.IMRT.IN':'infmort', 'SN.ITK.MSFI.ZS':'foodinsec', 'SI.DST.FRST.10':'inclow10', 'SI.DST.10TH.10':'inchigh10','SP.ADO.TFRT':'adolefert', 'SL.UEM.NEET.FE.ZS':'femneec', 'SL.UEM.NEET.MA.ZS':'maleneec', 'SG.LAW.INDX':'wbli', 'SG.GEN.PARL.ZS':'womparl', 'SE.TER.TCHR.FE.ZS':'femtereduc', 'NY.GDP.PCAP.KD':'gdppercap'}
Is there a way I can easily replace the labels in the correlation matrix from the keys of this dictionary to the values? I was hoping there was some way I could easily map it but I'm struggling to find this anywhere.
Thanks!
