Custom colors for dendrogram based on clusters

I’m using a scatter plot to show clusters. And each cluster has a color.

I’m also showing that clustering on a dendrogram.

How can I make the colors from the scatter be the same as the ones shown on the dendrogram?

Looks like the create_dendrogram from ff can accept a list of colors, but I don’t believe is as simple as providing a color scale. The colors aren’t chosen the same way.

So I figured out how to make my own color scale. And how to make a list of colors equal to the number of clusters. And I made a dictionary to make a color map

for index, color in enumerate(colors):
                color_map[f'{index + 1}'] = color

I also gave my dendrogram hover text and used that to update the colors.

for key, value in color_map.items():
                dendro.update_traces(marker=dict(color=value), selector=(dict(text=key)))

But I’m not sure I’m adding the hover text quite right, because the traces for one cluster go all the way to the top.

Anyway, sorry if this is a mess.

Bottom line: I’m trying to match the cluster color from my scatter plot to the colors in the dendrogram.