'How to plot live data in python without a fixed interval?

The standard method to plot live data in python seems to be the matplotlib animation interface. However, this requires a fixed update frequency in FuncAnimation(). My code looks (simplified) like this:

def foo(image):
  # compute something
  return value

cap = cv2.VideoCapture(0)
i=0
while True:
  ret, img = self.cap.read()
  i += 1
  y = foo(img)
  # update plot (i, y)
  cv2.imshow("window", img)
  cv2.waitKey(1)

How could I achieve this "update plot"? It would be great if it didn't add much delay of cause. I'm open for pretty much any library.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source