I have made the clustermap below using seaborn. As can be seen, there are three identifiable clusters here, two small onces at the top and bottom and a big one in the middle. I would like to extract the indices of the clusters and colourcode the three branches of the dendogram. If I enlarge the figure I can extract the indices manually but I assume there is a better way to do this. Ideally, I would just tell it to take 3 clusters, provide me with these clusters and automatically do the colourcoding for me. Anyone any tips?
code:
agerange = df_cor_small.pop("agerange")
lut = dict(zip(agerange.unique(), "rbg"))
row_colors = agerange.map(lut)
ax = sns.clustermap(df_cor_small, cmap='YlGnBu', row_colors=row_colors, figsize=(15,100), cbar_pos=(1.05, .2, .03, .4))
