for i in range(10):
    x = np.append(x, i)
y = np.append(y, i ** 2)
plt.gca().cla()
plt.plot(x, y, label='test')
plt.legend()
display.clear_output(wait=True)
display.display(plt.gcf())
time.sleep(0.5)
Dynamically update plot in iPython notebook