Only the first row of annotations displayed on seaborn heatmap

Question:

As it’s usually advised, I have managed to reduce my problem to a minimal reproducible example:

import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

matrix = np.array([[0.1234, 1.4567, 0.7890, 0.1234],
                   [0.9876, 0, 0.5432, 0.6789],
                   [0.1111, 0.2222, 0, 0.3333],
                   [0.4444, 0.5555, 0.6666, 0]])
sns.heatmap(matrix, annot=True)
plt.show()

Vaguely based on Seaborn official documentation.

Unfortunately, unlike what would be expected (all numbers visible), I get only the numbers in the top row visible:

enter image description here


As there is not really much room for error in this one, I’m out of ideas and google/SO doesn’t seem to have this question asked before. Is this a bug?


I am running:

Seaborn 0.12.2
Matplotlib 3.8.0
PyCharm 2023.1.4
Windows 10

Answers:

Thanks to a comment by @mwaskom, it seems like it’s a Matplotlib issue with a documented solution:

Looks like problem goes away if I downgrade MATPLOTLIB to version 3.7.3.

For those on earlier versions.

I am using seaborn version 0.13.0 and it works nicely.

Answered By: D.L

Yes, issue was for Seaborn 0.12.2, Seaborn 0.13.0 solves the issue.

Answered By: Gabe

Just ran into the issue myself, I was on Seaborn 0.12.2. Ran pip install seaborn --upgrade and now have 0.13.0

Restarted vscode and annotations appeared.

Answered By: dandex200
!pip install seaborn --upgrade

In vscode works fine for me in macbook pro m1.
Relaunch after upgrade.

Answered By: Disperser1019
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.