Watch closely as the GUI starts up. The first iteration appears to be doubling for some reason. I have the frames parameter set to 4 (equivalent to range(4)), so we should only see four points, but we have 5. Here is the code:
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import random
def animate(_):
x = random.uniform(0, 10)
y = random.uniform(0, 10)
plt.scatter(x, y, color='maroon', marker='x')
plt.xlim((0, 10))
plt.ylim((0, 10))
ani = FuncAnimation(plt.gcf(), animate, frames=4, interval=1000, repeat=False)
plt.show()
How can this be fixed?
