I have the following code:
sim = simulator()
fig, ax = plt.subplots()
scat = ax.scatter(sim.XY[:,0],sim.XY[:,1])
def animate(i):
sim.run()
scat.set_offsets(sim.XY) # update the data.
return scat
ani = FuncAnimation(fig, animate, interval=10, blit=True, save_count=50)
The "sim" object method "sim.run()" updates sim.XY which is (100,2) array.
After my 3rd line I get a scatter plot as expected.
But when I try to animate (from line 5 downwards) I get a error message saying. Can someone help please:
Traceback (most recent call last):
File "C:\Users\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 216, in process
func(*args, **kwargs)
File "C:\Users\anaconda3\lib\site-packages\matplotlib\animation.py", line 953, in _start
self._init_draw()
File "C:\Users\\anaconda3\lib\site-packages\matplotlib\animation.py", line 1732, in _init_draw
self._draw_frame(next(self.new_frame_seq()))
File "C:\Users\anaconda3\lib\site-packages\matplotlib\animation.py", line 1761, in _draw_frame
key=lambda x: x.get_zorder())
TypeError: 'PathCollection' object is not iterable