如何对树状图的叶子标签进行聚类?

时间:2019-04-12 05:34:53

标签: python matplotlib dendrogram

我有一个树状图,我希望能够列出叶子值或列表值而不必费力地将它们制成

我正在尝试根据颜色分组。下面的代码返回未定义defaultdict的错误 编辑:现在它告诉我元组对象不可调用

cluster_idxs = defaultdict(list)
for c, pi in zip(den['color_list'], den['icoord']):
    for leg in pi[1:3]:
        i = (leg - 5.0) / 10.0
        if abs(i - int(i)) < 1e-5:
            cluster_idxs[c].append(int(i))

TypeErrorTraceback (most recent call last)
<ipython-input-47-76b947227db4> in <module>()
----> 1 cluster_idxs = defaultdict(list)
      2 for c, pi in zip(den['color_list'], den['icoord']):
      3     for leg in pi[1:3]:
      4         i = (leg - 5.0) / 10.0
      5         if abs(i - int(i)) < 1e-5:

 TypeError: 'tuple' object is not callable   

0 个答案:

没有答案