Tell us what’s happening:
I am having trouble filling my heatmap with values. When I look at the heatmap my code generates, it does not have the values inside of the squares. I did the annot=True in my code but it still does not appear in the figure. Am I missing something?
Your code so far
Draw Heat Map
def draw_heat_map():
# Clean the data
df_heat = df[(df[‘ap_lo’] <= df[‘ap_hi’]) & (df[‘height’] >= df[‘height’].quantile(0.025)) & (df[‘height’] < df[‘height’].quantile(0.975)) & (df[‘weight’] >= df[‘weight’].quantile(0.025)) & (df[‘weight’] < df[‘weight’].quantile(0.975))]
# Calculate the correlation matrix
corr = df_heat.corr()
# Generate a mask for the upper triangle
mask = np.triu(corr)
# Set up the matplotlib figure
fig, ax = plt.subplots(figsize=(12,12))
# Draw the heatmap with 'sns.heatmap()'
sns.heatmap(data=corr,annot=True,mask=mask, linewidths=1, square=True, fmt=‘.1f’, center= 0.08, cbar_kws= {‘shrink’:0.5}).figure
# Do not modify the next two lines
fig.savefig(‘heatmap.png’)
return fig
My figure:
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.41
Challenge: Data Analysis with Python Projects - Medical Data Visualizer
Link to the challenge: