Dendrogram generated by scipy-cluster customisation

匆匆过客 提交于 2019-12-12 12:35:29

问题


This is a follow up to 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()

when dendrogram() returns a dictionary with keys ivl, leaves, color_list, icoord that pyplot is picking up. How can I modify the labels and the leaf length before they are passed to pyplot?

Doing something like:

d=dendrogram( Z )
d['leaves']=['label1','label2','label3','label4','label5']

does not seem to affect it.

The leaf length should be something like this:


回答1:


According the dendrogram documentation, you should be able to define labels when you are calling it (either via labels or leaf_label_func args). So there is no need to try to tamper afterwards with labels.



来源:https://stackoverflow.com/questions/5459341/dendrogram-generated-by-scipy-cluster-customisation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!