I am receiving data on my client and I have to plot them dynamically using matplotlib. I want to update my plot continuously. Here is what I tried on a simple example:
import time
import numpy as np
import matplotlib.pyplot as plt
h, = plt.plot([], [])
plt.ion()
plt.show()
for i in range(0, 100):
t = np.arange(i * 0.05, (i+1) * 0.05, 0.01)
y = np.sin(2*np.pi*t)
h.set_xdata(np.append(h.get_xdata(), t))
h.set_ydata(np.append(h.get_ydata(), t))
plt.draw()
time.sleep(0.05)
But nothing is plotting (neither in python2.7 nor 3), if I remove the activation of interactive mode (ion()) then I get an empty plot (show() call) but nothing is updated (the program seems to pause and don't go in the loop).
Can someone help?