I want to color my clusters with a color map that I made in the form of a dictionary (i.e. {leaf: color}).
I\'ve tried following https://joernhees.de/
Two-liner for applying custom colormap to cluster branches:
import matplotlib as mpl
from matplotlib.pyplot import cm
from scipy.cluster import hierarchy
cmap = cm.rainbow(np.linspace(0, 1, 10))
hierarchy.set_link_color_palette([mpl.colors.rgb2hex(rgb[:3]) for rgb in cmap])
You can then replace rainbow by any cmap and change 10 for the number of cluster you want.
