How to mask certain values in seaborn heatmap?

Viewed 297

I have a heatmap that looks like this. I want to show correlation values that are only +/- 0.25.

seaborn heatmap

How to do this? Thank you.

1 Answers

I believe you want to do this.

con_corr = df_continuous.corr()
mask_con_corr = con_corr[(con_corr >= 0.25) | (con_corr <= -0.25)]

fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(15,15))
fig = sns.heatmap(mask_con_corr, vmin=-1, vmax=1, annot=True, fmt='0.2f')
fig.set_title("Heatmap of Correlation (Weaker Correlation)")
Related