如何使用`sns.heatmap`的`annot`方法在Python和Seaborn中提供自定义标签?

时间:2016-08-02 17:24:57

标签: python matplotlib heatmap seaborn data-science

如何使用annot的{​​{1}}方法为其提供自定义命名方案?

基本上,我想删除所有低于我的阈值的标签(在这种情况下为0)。我试着做@ojy在Custom Annotation Seaborn Heatmap中所说的但是我收到了以下错误。我看到一个例子,有人遍历每个单元格,这是唯一的方法吗?

sns.heatmap

所以我尝试了以下内容:

Seaborn documentation:
annot : bool or rectangular dataset, optional
If True, write the data value in each cell. If an array-like with the same shape as data, then use this to annotate the heatmap instead of the raw data.

enter image description here

在面具(左)之前,在面具之后(右)

1 个答案:

答案 0 :(得分:1)

这很简单!

更新到0.7.1并重新启动Jupyter内核。

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