首页 > 解决方案 > 面临 seaborn.heatmap() 的问题

问题描述

我正在使用 JupyterLab。当我从事数据可视化工作时,我遇到了seaborn.heatmap(). 单元格不均匀,图中的值不可见。
这是代码片段和输出。
海博恩

我正在使用图书馆提供的提示数据集。 我什至在 IDLE 中尝试过,但遇到了同样的问题。 seaborn

有没有办法解决这个问题。

标签: python-3.xseabornjupyter-lab

解决方案


也许这是与您正在使用的matplotlib版本相关的问题。看看这个答案:matplotlib/seaborn: first and last row cut in half of heatmap plot

但是您可以尝试手动设置轴:

import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
tips = sns.load_dataset('tips')
g=sns.heatmap(tips.corr(), annot= True)
g.set(ylim=(0,3))
g.set(xlim=(0,3))

正确绘图

我能够通过以下方式重现设置轴的“错误”:

g.set(ylim=(0.5,2.5))
g.set(xlim=(0,3))

重现错误


推荐阅读