【python】Seaborn画热力图,只显示第一行数字---seaborn与matplotlib版本问题

github上有这个讨论:Heatmap only has annotation text in the top row only · Issue #3478 · mwaskom/seaborn (github.com)翻译过来就是:热图仅在最上面一行有注释文本;

原因就是matplotlib 在2023年9月更新到了 3.8.0版本,改变了一些东西,而seaborn 最新版是0.12.0,还是2022年12月更新的。

等seaborn更新吧


import matplotlib.pyplot as plt
import seaborn as sns
matrix = np.random.randn(5, 5)
fig = plt.figure()
sns_plot = sns.heatmap(matrix, annot=True)
plt.show()

Seaborn画热力图,只显示第一行数字

【python】Seaborn画热力图,只显示第一行数字---seaborn与matplotlib版本问题_第1张图片

貌似是版本问题,我这边换了另一个能正常画出热力的虚拟环境,再试一次是有用的 。

怀疑是matplotlib或numpy版本问题(seaborn依赖这些包),感觉可能是经过逐个降级,发现是maplotlib版本过高

原来版本:matplotlib = 3.8.0,seaborn = 0.12.0

现在版本:matplotlib = 3.7.3,seaborn = 0.12.0

现在有用了

【python】Seaborn画热力图,只显示第一行数字---seaborn与matplotlib版本问题_第2张图片

原因猜想:seaborn最先版在2022年12月更新,而matplotlib一直在更新,而3.8.0的API发生了变化,也许是这个原因导致的.

【python】Seaborn画热力图,只显示第一行数字---seaborn与matplotlib版本问题_第3张图片

你可能感兴趣的:(python,matplotlib,开发语言)