I get some data in two arrays: one for time and one for value. When I reach 1000 points, I start the signal and build these points (x = time, y = value).
I need to keep the previous plots in one drawing, but only a reasonable number to avoid slowing down the process. For example, I would like to save 10,000 points on my graph. The matplotlib interactive plot works fine, but I don’t know how to erase the first glasses, and it slows down my computer very quickly. I looked into matplotlib.animation, but it seems to be repeating the same plot and not updating it.
I am really looking for an easy solution to avoid slowdown.
As I get for a very large amount of time, I delete the input in each loop (the 1001st point is stored in the 1st line, etc.).
Here is what I have at the moment, but it saves all the points on the chart:
import matplotlib.pyplot as plt
def init_plot():
plt.ion()
plt.figure()
plt.title("Test d\'acqusition", fontsize=20)
plt.xlabel("Temps(s)", fontsize=20)
plt.ylabel("Tension (V)", fontsize=20)
plt.grid(True)
def continuous_plot(x, fx, x2, fx2):
plt.plot(x, fx, 'bo', markersize=1)
plt.plot(x2, fx2, 'ro', markersize=1)
plt.draw()
I call the init function once, and the continuum_plot is in a process called every time I have 1000 points in my array.