如何抑制绘制树状图但仍然聚集在seaborn中? [英] How to suppress drawing dendrograms but still cluster in seaborn?

查看:45
本文介绍了如何抑制绘制树状图但仍然聚集在seaborn中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 seaborn 中绘制一个集群图,按行和列进行聚类.我不想绘制树状图.

I want to plot a clustermap in seaborn, clustered by both rows and columns. I do not want to draw the dendrograms.

设置 row_cluster=Falsecol_cluster=False 会移除树状图,但也会停止聚类.

Setting row_cluster=False or col_cluster=False removes the dendrograms, but also stops the clustering.

如何仍然使用 2D 聚类但抑制树状图?

这个问题提供了设置宽度的技巧树状图行数为 0.此 hack 在 seaborn 0.7.1 中不起作用.

This question provides a hack of setting the width of the dendrogram lines to 0. This hack does not work in seaborn 0.7.1.

推荐答案

答案隐藏在文档中.

cg 成为 Seaborn 返回的 clustermap 实例.

Let cg be the clustermap instance returned by Seaborn.

绘制聚类图后,键入以下内容以删除行树状图.

After drawing the clustermap, type the following to remove the row dendrogram.

cg.ax_row_dendrogram.set_visible(False)

如果要保留图例,请键入:

If you want to preserve the legend, type:

cg.ax_row_dendrogram.set_xlim([0,0])

这是一个 hack,但是 set_axis_off() 在 Seaborn 中似乎没有在 matplotlib 中做的那样.

This is a hack, but set_axis_off() does not seem to do in Seaborn what it does in matplotlib.

这篇关于如何抑制绘制树状图但仍然聚集在seaborn中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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