更改海洋热图中的某些正方形 [英] change certain squares in a seaborn heatmap

查看:77
本文介绍了更改海洋热图中的某些正方形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个看起来像这样的热图(修剪掉了轴):

Say I have a heatmap that looks like this (axes are trimmed off):

我希望能够更改某些正方形以表示统计意义.我知道我可以遮盖统计上不显着的平方,但我仍想保留该信息(而不是将值设置为零).执行此操作的选项包括:1)使某些正方形上的文本加粗,2)添加类似填充图案的功能,以便某些正方形具有点画法,或者3)在某些正方形上添加符号.

I want to be able to alter certain squares to denote statistical significance. I know that I could mask out the squares that are not statistically significant, but I still want to retain that information (and not set the values to zero). Options for doing this include 1) making the text on certain squares bold, 2) adding a hatch-like functionality so that certain squares have stippling, or 3) adding a symbol to certain squares.

对此有何想法?谢谢!

Any ideas on this? Thanks!

推荐答案

您可以绘制两次,对不想再强调的单元格应用蒙版:

You could plot twice, applying a mask to the cells you do not want to emphasize the second time:

import numpy as np
import seaborn as sns
x = np.random.randn(10, 10)
sns.heatmap(x, annot=True)
sns.heatmap(x, mask=x < 1, cbar=False,
            annot=True, annot_kws={"weight": "bold"})

这篇关于更改海洋热图中的某些正方形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆