So I have been trying to get a plot to update every iteration through a loop. A stripped down version of my code is as follows:
  1 import matplotlib.pyplot as plt
  2 import numpy as np
  3 
  4 x = np.linspace(0, 9, 10)
  5 for j in range(10):
  6     y = np.random.random(10)
  7     plt.plot(x,y)
  8     plt.show()
  9     plt.pause(1)
 10     plt.clf()
My issue is that I have to close each plot before the next one is created; it seems like the plot is stuck on plt.show(), whereas I expect a new plot to replace the current one every second without needing my interaction. I've consulted the following questions:
When to use cla(), clf() or close() for clearing a plot in matplotlib?
Python plt: close or clear figure does not work
Matplotlib pyplot show() doesn't work once closed
But none of the solutions seemed to work for me. Any help would be appreciated!
 
    