title: How to plot and change the plotfunction at the same time?
body: <p>I want to plot points, and while doing so have a slidebar that I can adjust, which changes the function. 
  I found this example <a href="http://matplotlib.org/1.4.2/examles/widgets/slider_demo.html" rel="nofollow">here</a> that works. Now I want to plot points in a loop and change the function while the loop is still running.</p>
  
  <p>I changed the example and it has become this. Problem: the points are being plotted <strong>inside the reset button!</strong></p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from matplotlib.widgets import Slider, Button
  import random
  import time
  
  x=[]
  y=[]
  a=5
  
  fig = plt.subplots()
  plt.subplots_adjust(bottom=0.25)
  schuifa = Slider(plt.axes([0.125, 0.1, 0.775, 0.03],axisbg='lightgoldenrodyellow'), 'a', 0, 30.0, valinit=1)
  
  def update(val):
      a=schuifa.val
      fig.canvas.draw_idle()
  
  schuifa.on_changed(update)
  
  button = Button(plt.axes([0.8, 0.025, 0.1, 0.04]),'Reset',color='lightgoldenrodyellow', hovercolor='0.975')
  
  def reset(event):
      schuifa.reset()
  
  button.on_clicked(reset)
  
  for t in range(0,5):
      s=a*random.random()
      x.append(t)
      y.append(s)
  
  #plt.axis([0, 1, -10, 10])
  plt.scatter(t,s)
  
  #fig.canvas.draw_idle()
  plt.draw()
  
  plt.show()
  time.sleep(0.1)
  </code></pre>