Seaborn clustermap 行颜色与图例 [英] Seaborn clustermap row color with legend

查看:72
本文介绍了Seaborn clustermap 行颜色与图例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了以下解决方案来向 Seaborn clustermap 添加行颜色图例:

I found the following solution to add a row color legend to a Seaborn clustermap:

如何在Seaborn 中热图的轴

我有两个相关的问题:

  1. 如何将图例移动到集群地图的底部?
  2. 如果表示 row_color 的数据帧的索引有一个名称,它会显示为彩色行下方的标签.如何增加该标签的字体大小?

推荐答案

要添加颜色图例,首先需要创建legend_TN.

In order to add color legend, first, you need to create legend_TN .

import matplotlib.patches as mpatches
import seaborn as sns
legend_TN = [mpatches.Patch(color=c, label=l) for c,l in df[['tissue type','label']].drop_duplicates().values]

然后 g=sns.clustermap(...)

l2=g.ax_heatmap.legend(loc='center left',bbox_to_anchor=(1.01,0.85),handles=legend_TN,frameon=True)
l2.set_title(title='tissue type',prop={'size':10})

这篇关于Seaborn clustermap 行颜色与图例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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