这是后续的Dendrogram generated by scipy-cluster does not show.
from matplotlib.pyplot import show
from scipy.spatial.distance import pdist
from scipy.cluster.hierarchy import linkage, dendrogram
from numpy.random import rand
X = rand( 5, 3 )
X[0:5, :] *= 2
Y = pdist( X )
Z = linkage( Y )
dendrogram( Z )
show()
当dendrogram()返回带有ivl键,叶,color_list和pyplot正在拾取的icoord的字典时.在传递给pyplot之前,如何修改标签和叶的长度?
做类似的事情:
d=dendrogram( Z )
d['leaves']=['label1','label2','label3','label4','label5']
似乎没有影响它.
叶的长度应该是这样的:
解决方法:
根据dendrogram documentation,您应该能够在调用它时定义标签(通过标签或leaf_label_func args).因此,以后无需尝试篡改标签.