I wrote a python script that uses a heuristic to cluster 2D points in space. I'm representing each cluster using different cluster.

Presently,
the structure of my program is:

```
def cluster():
   while True:
       <do_some_work>
       if <certain_condition_is_met>:
            print "ADDED a new cluster:",cluster_details
       if <breaking_condition_is_met>:
            break
   return Res

def plot_cluster(result):
    <chooses a unique color for each cluster, and calls 
    pyplot.plot(x_coods,y_coods)
    for each cluster>

def driver_function():
   result = cluster()
   plot_cluster(result)
   pyplot.show()

```

That is, presently, I just obtain the final image of clustered points, where each cluster is represented by a different color.

However, I need to create an animation of how the program proceeds, i.e., something like:
"Initially, all points should be of same color, say blue. Then, as is cluster() function, instead of simply printing "ADDED a new cluster", the color of those points in the new cluster, should be changed in the image already present on screen.

Is there any way I can generate a video of such a program using matplotlib?
I saw an example of 

```
`matplotlib.animation.FuncAnimation( ..., animate, ...)`

```

but it repeatedly calls the animate function that should return plottable values, which I think my program cannot.

Is there any way to obtain such a video of how this program proceeds?