I can color tags in Python Dendrograms, but I don't know how to color parts of links belonging to its shortcuts. I want to do something like this:

Is this possible in Python?
Here I highlight only the labels:
import numpy as np import matplotlib.pyplot as plt import scipy.cluster.hierarchy as sc dists = np.array([[0,2,1,4],[2,0,3,5],[1,3,0,6],[4,5,6,0]]) l = ['a','b','c','b'] Z = sc.linkage(dists, method='complete') d = sc.dendrogram(Z, labels=l) label_colors = {'a': 'r', 'b': 'g', 'c': 'm'} ax = plt.gca() xlbls = ax.get_xmajorticklabels() for i in range(len(xlbls)): xlbls[i].set_color(label_colors[xlbls[i].get_text()]) plt.show()
python scipy colors dendrogram
Stalefish
source share