Skip to content Skip to sidebar Skip to footer

How To Update Curve Plot In Animation ( Tkinter) Of Python

from the following code, I could update the line by clicking the 'replot' button. I have to use both set_data() and also plot a new plot, otherwise the old plot is still here. Howe

Solution 1:

Not sure about the programming logic, but I think there maybe at least three issues.

  1. start_time won't be reset if you don't click 'collect', so it won't replot every 5 seconds.
defclickstart(self):
        ....
        start_time = time.time()
        aniplot_photon = animation.FuncAnimation(f, animate, blit=True,interval=100)
        ....
  1. first_replot initially set to 0, after 'collect' clicked and 5 seconds passed, then the value of first_replot will be always 1. It means no more replot in function 'animate'.

  2. canvas.draw at last line of function 'replot', should be canvas.draw().

Post a Comment for "How To Update Curve Plot In Animation ( Tkinter) Of Python"