matplotlib/seaborn: first and last row cut in half of heatmap plot

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


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)

Unfortunately matplotlib 3.1.1 broke seaborn heatmaps; and in general inverted axes with fixed ticks.
This is fixed in the current development version; you may hence

  • revert to matplotlib 3.1.0
  • use matplotlib 3.1.2 or higher
  • set the heatmap limits manually (ax.set_ylim(bottom, top) # set the ylim to bottom, top)

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)