import matplotlib.pyplot as plt
import numpy as np


def display_result(vectors, clusters):
    colors = [np.random.rand(3, 1) for i in range(len(clusters))]
    for cluster_index, (centroid, cluster) in enumerate(clusters.items()):
        plt.scatter(centroid[0], centroid[1], c=colors[cluster_index], marker='x')
        for vector_index in cluster:
            plt.scatter(vectors[vector_index][0], vectors[vector_index][1], c=colors[cluster_index])
    plt.show()

@@ -238,191 +238,262 @@
     
-plt.scatter(centroid%5B0%5D, centroid%5B1%5D, c=colors%5Bcluster_index%5D, marker='x')%0A        for vector_index in cluster:%0A            plt.scatter(vectors%5Bvector_index%5D%5B0%5D, vectors%5Bvector_index%5D
+current_cluster = %5Bvectors%5Bi%5D for i in cluster%5D%0A        xs = list(map(lambda x: x%5B0%5D, current_cluster))%0A        ys = list(map(lambda x: x%5B1%5D, current_cluster))%0A        plt.scatter(xs, ys, c=colors%5Bcluster_index%5D)%0A        plt.scatter(centroid%5B0%5D, centroid
 %5B1%5D,
@@ -512,24 +512,36 @@
 uster_index%5D
+, marker='x'
 )%0A    plt.sh

Improve drawing speed