title: matplotlib FuncAnimation won't start on button press widget event
body: <p>matplotlib noob here.</p>
  <p>I am trying to create an animation (which starts on a button click) of a normal distribution being populated, where the distribution parameters (mean and std dev) are selected using two slider widgets.</p>
  <p>Please help. I have pasted my code below</p>
  <pre><code>%matplotlib notebook
  from pdb import set_trace as bp
  import matplotlib.animation as animation
  import numpy as np
  from matplotlib.widgets import Slider, Button, RadioButtons
  
  
  fig = plt.figure()
  
  n = 1000
  
  x = np.array([])
  bins = np.arange(-4, 4, 0.5)
  
  plt.hist(x, bins=bins)
  plt.subplots_adjust(bottom=0.25)
  
  def update(curr):
      if curr == n: 
          a.event_source.stop()
  
      plt.cla()
      plt.hist(x[:curr], bins=bins)
      plt.axis([-4,4,0,500])
      plt.gca().set_title('Sampling the Normal Distribution')
      plt.gca().set_ylabel('Frequency')
      plt.gca().set_xlabel('Value')
      plt.annotate('n = {}'.format(curr), [3,480])
  
  axcolor = 'lightgoldenrodyellow'
  axmu = plt.axes([0.15, 0.1, 0.65, 0.03], facecolor=axcolor)
  axstdev = plt.axes([0.15, 0.15, 0.65, 0.03], facecolor=axcolor)
  
  muslider = Slider(axmu, 'mean', 0.1, 30.0, valinit=0)
  stdevslider = Slider(axstdev, 'stdev', 0.1, 10.0, valinit=1.0)
  
  startax = plt.axes([0.4, 0.025, 0.1, 0.04])
  startbutton = Button(startax, 'Start', color=axcolor, hovercolor='0.975')
  
  newmean = 0
  newstdev = 1.0
  
  def getnewparams(val):
      global newmean
      global newstdev
      newmean = muslider.val
      newstdev = stdevslider.val
      
  def startanimation(event):
      print(f&quot;params now is {newmean} {newstdev}&quot;)
      global x
      x = np.random.normal(loc=newmean, scale=newstdev, size=n)
  
      a = animation.FuncAnimation(fig, update, interval=100)
      a.event_source.start()
      
  muslider.on_changed(getnewparams)
  stdevslider.on_changed(getnewparams)
  startbutton.on_clicked(startanimation)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/oDIsd.png" rel="nofollow noreferrer">How my plot looks now</a></p>