I'm trying to plot a signal with Matplotlib and the plot is within while
. What I want is that every time I go through the while
a graph is opened and then either immediately or after a time that I can control it will close. I have something more or less like that, but it does not work.
import matplotlib.pyplot as plt
from Ciclo import ciclo
b = ciclo()
g = []
pin = 1
while (True):
val = b.cicloHigh(pin)
t = t + 1
res = int((int(val)*250000)/1023)
g.append(res)
print("%s ............... %s"%(res, t))
plt.figure(1)
plt.plot(g)
plt.show()
plt.close()
time.sleep(0.1)
Because plt.show()
is a cycle then it never closes unless it is manual.
And I want it to open and close once or if it is possible to close at a certain time, but I do not achieve either of the two.