【发布时间】:2021-09-08 08:10:22
【问题描述】:
我想以组的相同颜色生成图的标签。我该怎么做?
简单示例测试:
import numpy as np
from scipy.cluster.hierarchy import dendrogram, linkage
import matplotlib.pyplot as plt
mat = np.array([[1.0, 0.5, 0.0],
[0.5, 1.0, -0.5],
[1.0, -0.5, 0.5],
[0.0, 0.5, -0.5]])
dist_mat = mat
linkage_matrix = linkage(dist_mat, "single")
plt.clf()
ddata = dendrogram(linkage_matrix, color_threshold=0.8)
前面的代码生成了这个图:
但我想要蓝色的 0 和 2 索引以及红色的 1 和 3。
【问题讨论】:
标签: matplotlib scikit-learn label dendrogram