When plotting heatmaps with seaborn (and correlation matrices with matplotlib) the first and the last row is cut in halve. This happens also when I run this minimal code exa
Fixed using the above and setting the heatmap limits manually.
First
ax = sns.heatmap(...
checked the current axes with
ax.get_ylim()
(5.5, 0.5)
Fixed with
ax.set_ylim(6.0, 0)
Downgrade your matplotlib
!pip install matplotlib==3.1.0
and add this line to your plot code :
ax[i].set_ylim(sorted(ax[i].get_xlim(), reverse=True))
conda install matplotlib=3.1.0
This worked for me and downgraded matplotlib from 3.1.1 to 3.1.0 and the heatmaps started to behave correctly
Its a bug in the matplotlib regression between 3.1.0 and 3.1.1 You can correct this by:
import seaborn as sns
df_corr = someDataFrame.corr()
ax = sns.heatmap(df_corr, annot=True) #notation: "annot" not "annote"
bottom, top = ax.get_ylim()
ax.set_ylim(bottom + 0.5, top - 0.5)
I solved it by adding this line in my code, with matplotlib==3.1.1
:
ax.set_ylim(sorted(ax.get_xlim(), reverse=True))
NB. The only reason this works is because the x-axis isn't changed, so use at your own risk with future mpl versions
It happens with matplotlib version 3.1.1 as suggested by importanceofbeingernest
Following solved my problem
pip install matplotlib==3.1.0