Coloring clusters so that nearby clusters have different colors
matplotlib already takes care of coloring adjancent clusters with different colors. But, I believe it uses a unique color for each cluster. If that's the case, 400 colors would be too much.
There might be better ways, but worst case, try this:
We want to color with minimum number of colors. Hence, the problem turns to a graph coloring problem in which, we don't want two connected adjacent nodes have the same color. Finding the minimum number of colors is an np-hard problem but we can use approximate algorithms.
One way could be defining your cluster centroids as graph nodes and storing their connections and then using a graph coloring algorithm.
Step 1: Store your clusters as an adjacency matrix and convert this matrix to a graph wherein each centroid is the representative of a cluster and the adjacency matrix contains the connectivity(neighborhood) between each centroid and the others.
Explanation
Code
Step 2: use a coloring algorithm to color the nodes of the graph.
This post contains a coloring algorithm that gets the graph and returns the coloring for that.
Step 3: having the color of each centroid, you can color the whole clusters with minimum number of colors.