[Python] Scipy dendrogram leaf label colours

Discussão em 'Python' iniciado por Stack, Fevereiro 24, 2025.

  1. Stack

    Stack Membro Participativo

    Is it possible to assign colours to leaf labels of dendrogram plots from Scipy? I can't figure it out from the documentation. Here's what I've tried so far:

    from scipy.spatial.distance import pdist, squareform
    from scipy.cluster.hierarchy import linkage, dendrogram

    distanceMatrix = pdist(subj1.ix[:,:3])
    dendrogram(linkage(distanceMatrix, method='complete'),
    color_threshold=0.3,
    leaf_label_func=lambda x: subj1['activity'][x],
    leaf_font_size=12)


    Thanks.

    Continue reading...

Compartilhe esta Página