title: Update plots through slider (python)
body: <p>I got a data array looking like <code>data = [[1, 2, 3], [4, 5, 6], [7, 9, 10]....]</code> and x values <code>x_values = np.arange(3)</code>.</p>
  
  <p>I want to show the plot of one sub-array at a time and incorporate a slider in my graph whose value should represent the index of the corresponding sub-array. So when I change the slider from for example 1 to 2, it should change from plotting <code>data[1]</code> to plotting <code>data[2]</code> against my x values.</p>
  
  <p>My code looks something like this:</p>
  
  <pre><code>#Initial plot
  fig, ax = plt.subplots()
  i = 0
  plt.subplots_adjust(bottom = 0.15)
  ax.plot(x_values, data[i])
  
  #Update function
  def update_wave(val):
      i = int(sliderwave.val)
  
      x_values = np.arange(3)
      ax.cla()
      ax.plot(x_values, data[i))
      fig.canvas.draw_idle()
  
  #Sliders
  axwave = plt.axes([0.25, 0.05, 0.5, 0.03])
  sliderwave = Slider(axwave, 'Event No.', 0, 100, valinit=0, valfmt='%1.0f')
  
  update_wave(i)
  sliderwave.on_changed(update_wave)
  </code></pre>
  
  <p>It does not work like that. I guess some things don't make sense. Would appreciate some help.</p>