微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我想增加 searborn clustermap 行的最大符号数

如何解决我想增加 searborn clustermap 行的最大符号数

Please look at the "-" on the right

有200多行,但实际显示的“-”似乎连100个都没有。

如何使用 seaborn 的 clustermap 来显示所有行的标签

解决方法

可以保存clustermap的grid,然后访问底层的grid.ax_heatmap来调用set_ticks()set_ticklabels()

这是将 ytick 间隔降低到 20 的示例。您可以根据数据需要更改 interval 变量。

import seaborn as sns
import numpy as np
iris = sns.load_dataset('iris')
species = iris.pop('species')

# save grid object
grid = sns.clustermap(iris)

# adjust tick interval as desired
interval = 20

# create custom ytick array
bottom,top = grid.ax_heatmap.get_ylim()
yticks = np.arange(min(bottom,top),max(bottom,interval)

# set ticks and ticklabels on underlying ax_heatmap
grid.ax_heatmap.yaxis.set_ticks(yticks)
grid.ax_heatmap.yaxis.set_ticklabels(yticks)

iris clustermap with ytick interval of 20

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。