title: FuncAnimation in Python does not show the animation and saves an empty mp4 and does not display animation inn both spyder and Jupyter Notebook
body: <pre><code>import numpy as np
  
  import matplotlib.pyplot as plt
  from matplotlib.animation import FuncAnimation 
  plt.style.use('seaborn-pastel')
  
  
  ### random no. generated uniformly from 1 to 6
  x = np.random.uniform(low = 1 , high = 6 ,size = 10)
  x.mean()
  
  
  
  
  ### making a list of items for the plot
  avg = []
  trials = []
  for j in range(1,100000):
      x = np.random.uniform(low = 1 , high = 6 ,size = j).mean()
      avg.append(x)
      y = j
      trials.append(y)
  
  
  
  
  
  import matplotlib as mpl
  mpl.rcParams['agg.path.chunksize'] = 10000
  
  ax = plt.axes(xlim=(0,100000), ylim=(2, 4))
  line, = ax.plot([], [], lw=3)
  fig = plt.figure()
  
  def init():
      line.set_data([], [])
      return line,
  xdata , ydata = [], []
  def animate(i):
      x = trials
      y = avg
      xdata.append(x)  
      ydata.append(y)  
      line.set_data(xdata, ydata)
      return line,
  
  anim = FuncAnimation(fig, animate, init_func=init , frames = 500 ,interval = 20 , blit = True)
  
  anim.save('simulation1.mp4', dpi=150, fps = 30, writer='ffmpeg',extra_args=['-vcodec', 'libx264'])
  plt.show()
  </code></pre>
  
  <p>I am not able to understand why is the animation not happening in both jupyter notebook as well as spyder.
  Moreover, when i try to save the file as mp4 , then it saves as a blank video.
  Any help would be appreciated.</p>