0

Is there a way in matplotlib to add line segments between each point in the cluster to its centroid?

I have a plot that looks like this:

enter image description here

and I want the result to look like this: enter image description here

I have a two separate plots on top of each other. One with all the clusters and the other with the yellow centroids

zay_117
  • 67
  • 4
  • This link should help: https://stackoverflow.com/questions/36470343/how-to-draw-a-line-with-matplotlib or this https://stackoverflow.com/questions/21352580/matplotlib-plotting-numerous-disconnected-line-segments-with-different-colors – Chris Seeling Jul 14 '22 at 22:47
  • 1
    If you have the centroid coordinates and the points related to that centroid, you can do a simple `plt.plot([centroid_x, point_x], [centroid_y, point_y])` for every point you have, changing the colors as appropriate. – K.Cl Jul 15 '22 at 00:59

0 Answers0