The 20 plots have different ranges for their y axis. So, while the one shown in the figure above ranges from -184000 to -176000, another might range from -160000 to -170000. Keeping the axis constant in the range of the minimum and maximum of all graphs causes the plots to be too stretched out or shrunken.
I've written the following code:
import matplotlib.pyplot as plt import matplotlib.animation as animation fig = plt.figure() ims =  for i in range(1, 21): file_out = "out" + "_" + str(i) outfile = pd.read_table(file_out, \ skip_blank_lines=True, skipinitialspace=True, sep='\s+') x = outfile['col1'] y = outfile['col2'] im = plt.plot(x, y) ims.append(im) ani = animation.ArtistAnimation(fig, ims, repeat=False, interval = 500) plt.show()
Is there a way to change the axis ranges for each new graph in the animation? I tried adding the following line to the code but I was not successful: plt.axes(xlim = (0, 100), ylim = (min(y), max(y)))