Problems with Seaborn plots in Python
0
0
Entering edit mode
2 days ago
egascon ▴ 60

Hello everyone,

I was analyzing some data in my Jupyter notebook and the plots that were generated were coming out without problems but since a couple of weeks ago they are coming out as follows:

Correlation Matrix

Confusion Matrix

Plots are generated without errors, but numerical labels fail. The code I used was:

plt.figure(figsize=(12, 8))
sns.heatmap(correlation_matrix_original_AD, annot=True, cmap="coolwarm", fmt=".2f", linewidths=0.5)
plt.title(f"Correlation Heatmap", fontsize=16)
plt.show()

sns.heatmap(cm, annot=True, fmt="d", cmap="Blues", xticklabels=['Healthy', 'Diseased'],yticklabels=['Healthy', 'Diseased'])
plt.title("LASSO - Confusion Matrix")
plt.xlabel("Predicted")
plt.ylabel("Actual")
plt.show()

I suspect there is a problem with the function annot=True, it's possible?

Thank you for your help,

python sns plot • 209 views
ADD COMMENT
0
Entering edit mode

Similar errors have been discussed in the following Github issue threads.

https://github.com/mwaskom/seaborn/issues/3478

https://github.com/mwaskom/seaborn/issues/3479

ADD REPLY
0
Entering edit mode

Thank you for your help! I'ii take a look

ADD REPLY
0
Entering edit mode

Seaborn version 0.13.2 is listed as the latest version.
I just ran the supplied code at the top here that was supposed to reproduce the old issue that Arup brought up, and it annotates all the squares using Seaborn version 0.13.2 and Matplotlib version 3.10.1. So I am not seeing any issue with either Python 3.10 or 3.12.

You don't mention what versions of anything you are using?
Does the supplied code at the top here work in your situation?



If you want to test things independent of your own system on a temporary remote machine served via MyBinder.og, without needing to login or create any account, for compare and contrasting:

Go here for Python 3.10.
Or here for Python 3.12.

In the gist you chose based on the Python version, click on the 'launch binder' badge.

When the session comes up open a new notebook and run the following in the first cell:

%pip install seaborn

Then when that successfully completes running run the demo code at the top there. (To be thorough you should restart the kernel after installation; however, it doesn't seem to matter for this use. It can matter more for other packages.)

ADD REPLY

Login before adding your answer.

Traffic: 1358 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6