Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heatmap only has annotation text in the top row only #3478

Closed
pybokeh opened this issue Sep 17, 2023 · 14 comments
Closed

Heatmap only has annotation text in the top row only #3478

pybokeh opened this issue Sep 17, 2023 · 14 comments
Labels

Comments

@pybokeh
Copy link

pybokeh commented Sep 17, 2023

Example to duplicate the problem:

# Required libraries 
import seaborn as sns
import matplotlib.pyplot as plt

# Load the iris dataset into a Pandas dataframe
iris_data = sns.load_dataset('iris')

# Creating the correlation matrix of the iris dataset
iris_corr_matrix = iris_data.corr(numeric_only=True)
print(iris_corr_matrix)

# Create the heatmap using the `heatmap` function of Seaborn
sns.heatmap(iris_corr_matrix, cmap='coolwarm', annot=True)

# Display the heatmap using the `show` method of the `pyplot` module from matplotlib.
plt.show()

My environment:
Python 3.11.4 virtual environment via venv module, everything installed with pip
OS: Ubuntu 22.04
Seaborn version: 0.12.2
Pandas version: 2.1.0
MATPLOTLIB version: 3.8.0

My pip list output:
Package Version


asttokens 2.4.0
atpublic 4.0
backcall 0.2.0
bidict 0.22.1
certifi 2023.7.22
charset-normalizer 3.2.0
comm 0.1.4
contourpy 1.1.1
cycler 0.11.0
debugpy 1.8.0
decorator 5.1.1
duckdb 0.8.1
duckdb-engine 0.9.2
executing 1.2.0
filelock 3.12.4
fonttools 4.42.1
greenlet 2.0.2
ibis-framework 6.2.0
idna 3.4
ipykernel 6.25.2
ipython 8.15.0
jedi 0.19.0
jupyter_client 8.3.1
jupyter_core 5.3.1
kiwisolver 1.4.5
markdown-it-py 3.0.0
matplotlib 3.8.0
matplotlib-inline 0.1.6
mdurl 0.1.2
multipledispatch 1.0.0
nest-asyncio 1.5.7
numpy 1.26.0
packaging 23.1
pandas 2.1.0
parso 0.8.3
parsy 2.1
patsy 0.5.3
pexpect 4.8.0
pickleshare 0.7.5
Pillow 10.0.1
pip 23.2.1
platformdirs 3.10.0
pooch 1.7.0
prompt-toolkit 3.0.39
psutil 5.9.5
ptyprocess 0.7.0
pure-eval 0.2.2
pyarrow 12.0.1
Pygments 2.16.1
pyparsing 3.1.1
python-dateutil 2.8.2
pytz 2023.3.post1
pyzmq 25.1.1
requests 2.31.0
rich 13.5.2
scipy 1.11.2
seaborn 0.12.2
setuptools 65.5.0
six 1.16.0
SQLAlchemy 2.0.20
sqlalchemy-views 0.3.2
sqlglot 17.16.2
stack-data 0.6.2
statsmodels 0.14.0
toolz 0.12.0
tornado 6.3.3
tqdm 4.66.1
traitlets 5.10.0
typing_extensions 4.7.1
tzdata 2023.3
urllib3 2.0.4
wcwidth 0.2.6
xxhash 3.3.0

@pybokeh
Copy link
Author

pybokeh commented Sep 17, 2023

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

@mwaskom
Copy link
Owner

mwaskom commented Sep 17, 2023

Hm, I cannot replicate

image

So maybe this has been already addressed on master, although nothing immediately comes to mind.

@stefanistrate
Copy link
Contributor

I am having the same issue with seaborn 0.12.2 from PyPI, but things seem to be work just fine with the github master branch. Maybe it's worth pushing a new version to PyPI soon?

Screenshot 2023-09-18 at 09 10 44
Screenshot 2023-09-18 at 09 13 42
Screenshot 2023-09-18 at 09 18 19

@mwaskom
Copy link
Owner

mwaskom commented Sep 18, 2023

It would be helpful for someone to track down the root cause here and determine if it needs to be reported upstream to matplotlib as a regression, independent of whether seaborn already has a workaround for it on the dev branch.

@thuiop
Copy link
Contributor

thuiop commented Sep 18, 2023

I'll try to take a look.

@thuiop
Copy link
Contributor

thuiop commented Sep 18, 2023

So the issue is that the value returned by pcolormesh is now a different class, as mentioned here. The get_array method no longer returns a flattened array by default.
This has been fixed by @ksunden in this commit b3e6b8d.

@mwaskom mwaskom changed the title Correlation heatmap only has correlation values for the top row only Heatmap only has annotation text in the top row only Sep 18, 2023
@mwaskom mwaskom pinned this issue Sep 18, 2023
@ylevental
Copy link

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

Downgrading worked for me too. It seems that this problem will be fixed soon in the pip release.

@mwaskom
Copy link
Owner

mwaskom commented Sep 29, 2023

Closing this as the issue is resolved in seaborn v0.13.0 which will be released in the next day or two barring any last-minute surprises about the RC.

@mwaskom mwaskom closed this as completed Sep 29, 2023
@mwaskom mwaskom unpinned this issue Sep 29, 2023
@mwaskom
Copy link
Owner

mwaskom commented Sep 29, 2023

I am guessing you updated seaborn in a different environment, or perhaps forgot to restart your kernel:
image

@engnadeau
Copy link

I am guessing you updated seaborn in a different environment, or perhaps forgot to restart your kernel: image

yeah, caught my error but you were too fast 🤣

@rv-12
Copy link

rv-12 commented Mar 28, 2024

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

worked for me

@paulinavita
Copy link

paulinavita commented Apr 1, 2024

Hi, I wonder why it's not working for me, I downgraded the matplotlib and update seaborn to latest already. Also restarted my kernel

image

I still only got the first row of the heatmap showing
image

My environment:
Python 3.11.4, everything installed with pip
OS: Mac OS Ventura 13.2.1
Seaborn version: 0.13.1
Pandas version: 2.2.1
MATPLOTLIB version: 3.7.3

Any step I am missing? Thank you

@mwaskom
Copy link
Owner

mwaskom commented Apr 1, 2024

I would confirm that you actually have those versions imported in the python process where you’re making the plot

@paulinavita
Copy link

Ah, sorry about that. Yes, I confirm it works now. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants