'Python scatterplot clustering

I have many scatterplots, that show subsequent events in time (i uploaded two pictures).I would like to separate these clusters of points and find their center of mass. The approach I thought of was using an automated k means clustering where I find the elbow point in order to determine the number of clusters, then perform the actual clustering. Of course this comes up with random cluster assignments, which I figured to combat with finding the center of mass of the points and then assigning the cluster label across the different scatterplots for clusters with the nearest center of mass.

My question is, whether anyone can recommend an easier and more robust method? As you can see from the second pictures, sometimes the clustering will result in more clusters than I would like, but I suppose if I tweak the clustering parameters I might be able to combat this, but if you have any suggestions I would appreciate that too.

Thank you very much for your help!

All the best,

Gergely

enter image description here enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source