How do I plot in real-time in a while loop using matplotlib?

前端 未结 12 1238
天命终不由人
天命终不由人 2020-11-22 01:08

I am trying to plot some data from a camera in real time using OpenCV. However, the real-time plotting (using matplotlib) doesn\'t seem to be working.

I\'ve isolated

12条回答
  •  走了就别回头了
    2020-11-22 02:03

    The problem seems to be that you expect plt.show() to show the window and then to return. It does not do that. The program will stop at that point and only resume once you close the window. You should be able to test that: If you close the window and then another window should pop up.

    To resolve that problem just call plt.show() once after your loop. Then you get the complete plot. (But not a 'real-time plotting')

    You can try setting the keyword-argument block like this: plt.show(block=False) once at the beginning and then use .draw() to update.

提交回复
热议问题