Sep-20-2019, 10:03 AM

I need to animate a plot, the plot needs to have an imshow with two scatter plots over the imshow. At each timestep the imshow updates, pulling a grid of numbers from csv files, and the scatter needs to remain constant. So far I have managed to animate the imshow, but I cannot figure out how to plot the scatter over the imshow successfully, my code is below,

from pathlib import Path import matplotlib.pyplot as plt # from matplotlib import animation from matplotlib.animation import ArtistAnimation, FFMpegFileWriter, FFMpegWriter import matplotlib.animation as animation import numpy as np plt.rcParams['animation.ffmpeg_path'] = str(Path("../resources/bin/ffmpeg.exe")) n = 100 # The number of files that the plot iterates through fig = plt.figure() ax = plt.axes(xlim=(220, 800), ylim=(200, 400)) def f(m): # the function that updates the block of imshow data data = np.loadtxt('Concentration_Output/%s.csv' % m, delimiter=',') return data maxx = 326.0 # the maximum imshow f1 = [250, 300] # the centres of the two circles that are plot with scatter plot f2 = [350, 300] N = 200 # The number of x and y points that plot the circle # circle: x1 = np.linspace(235, 265, N) y = np.linspace(285, 315, N) pointsx1 = [] pointsy1 = [] for i in x1: for j in y: if np.floor((i - f1[0])**2 + (j - f1[1])**2) == 15**2 or np.ceil(((i - f1[0])**2 + (j - f1[1])**2) == 15**2): pointsx1.append(i) pointsy1.append(j) # the points of the circle are then in pointsx1 and pointsy1, # I left the procedure for the second circle out ims = [] for i in range(n): # this adds the imshow objects to an array im = plt.imshow(f(i*10), vmin=0, vmax=maxx, aspect='auto', animated=True) ims.append([im]) # plt.scatter(pointsx1, pointsy1, s=1, c='r') # this is the scatter that needs to be plot # Set up formatting for the movie files Writer = animation.writers['ffmpeg'] writer = Writer(fps=15, metadata=dict(artist='Megz'), bitrate=1800) ani = ArtistAnimation(fig, ims, interval=100, blit=True) plt.show()I have no idea how to incorporate the changing imshow plot that updates from a file as well as the scatter plot over a imshow plot