title: _tkinter.TclError: this isn't a Tk application in matplotlib bar graph
body: <p>I have a program that analyzes certain videos and assigns a "score" every second based on the contents of the video. I have an example of some of the raw data that the program churns out, (x in seconds, y in score).</p>
  
  <pre><code>0 0
  1 27
  2 48
  3 78
  4 92
  5 72
  </code></pre>
  
  <p>etc etc. My goal is to create an animated graph that goes along with the video. For example, when 1 second of the video plays, point (1, 27) is plotted. When 2 seconds pass, point (2, 48) is plotted. I don't care about the merging of the video and animated graph for now; right now I only care about getting the graph to plot 1 bar every second.</p>
  
  <pre><code>from matplotlib import pyplot as plt
  import numpy as np
  import numpy
  from matplotlib import animation
  
  fig = plt.figure()
  ax = plt.axes(xlim=(0, 10), ylim=(0, 100)) #a 0 to 10 x axis and a 0 to 100 y
  line, = ax.plot([], [], lw=2)
  
  def init():
      line.set_data([], [])
      return line,
  
  def animate(i):
      with open('E:\PYTHON\data.txt') as f:
          lines = f.readlines()
          x = [float(line.split()[0]) for line in lines]
          y = [float(line.split()[1]) for line in lines]
  
      ax.bar(x,y, width=0.7)
      plt.show()
      plt.draw()
  
  ani = animation.FuncAnimation(fig, animate, interval=1000)
  
  plt.show()
  </code></pre>
  
  <p>However, this code ends up sending out all my data in one image, rather than an animation, and then gives me this error. I suppose the "sending out all my data in one image" part stems from me not utilizing "i" in my x and y values, but in all honesty, I have no idea how to implement "i" in my animation code.</p>
  
  <pre><code>Traceback (most recent call last):
    File "E:\PYTHON\lib\site-packages\matplotlib\cbook\__init__.py", line 388, in process
      proxy(*args, **kwargs)
    File "E:\PYTHON\lib\site-packages\matplotlib\cbook\__init__.py", line 228, in __call__
      return mtd(*args, **kwargs)
    File "E:\PYTHON\lib\site-packages\matplotlib\animation.py", line 1030, in _start
      self.event_source.add_callback(self._step)
  AttributeError: 'NoneType' object has no attribute 'add_callback'
  Exception in Tkinter callback
  Traceback (most recent call last):
    File "E:\PYTHON\lib\site-packages\matplotlib\backends\tkagg.py", line 26, in blit
      dataptr, colormode, bboxptr)
  _tkinter.TclError: this isn't a Tk application
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "E:\PYTHON\lib\tkinter\__init__.py", line 1702, in __call__
      return self.func(*args)
    File "E:\PYTHON\lib\site-packages\matplotlib\backends\_backend_tk.py", line 227, in resize
      self.draw()
    File "E:\PYTHON\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 13, in draw
      tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
    File "E:\PYTHON\lib\site-packages\matplotlib\backends\tkagg.py", line 34, in blit
      dataptr, colormode, bboxptr)
  _tkinter.TclError: this isn't a Tk application
  </code></pre>
  
  <p>Could anyone help me animate this bar graph?</p>