2

Let's say I have a function called trajectory that plots the position of a few objects in a 2D plot.

import matplotlib.pyplot as plt

def trajectory(listOfObjects, time):
   #Stuff happens here
   plt.scatter(x,y)

I iterate this function so it plots new points in the same graph, effectively plotting a full trajectory over enough iterations. Something like this:

while True:
   time += 1
   trajectory(listOfObjects, time)
   plt.pause(0.001)

Now I want this program to run embedded in a Tkinter window. How can I achieve this? I don't know how to run this loop indefinitely while also using tkinter's mainloop()

0 Answers0