fig = plt.figure()
ax = fig.add_subplot(111)
plt.ion()
fig.show()
fig.canvas.draw()
for i in range(0, 100):
    ax.clear()
ax.plot(matrix[(i), :])
fig.canvas.draw()
Plot dynamically changing graph using matplotlib in Jupyter Notebook