Does FuncAnimation allow any kind of sleep() function without blocking the plot?

Viewed 25

I'm writing a code for controlling multiple devices which communicate by Serial with Python, some of them take measurements and others control the conditions of those. I want to graph the data collected in real time, so I've used FuncAnimation from matplotlib for this purpose. My animate function has this structure:

def animate(i, data1, data2, device1, device2):
    device1.set_condition()
    time.sleep(0.2)
    device2.measure()

The device 1 sets a value in my system (Magnetic field, voltage, light, etc), then I must wait a small time interval for the stabilization of my system, so I've used time.sleep() for this, but the plot from FuncAnimation gets blocked for 0.2 s for every iteration because of this. Is there anyway to make FuncAnimation wait for this stabilization without getting blocked? Or is there any better way for achieving this?

0 Answers
Related