title: Matplotlib Animation does not update within class
body: <p>I'm writing a simple class to plot a sensor value in real-time; however, the animation does not run within the class.</p>
  
  <p>I've tried to return the animation object to have an instance outside of the class but this does not work.</p>
  
  <p>To my understanding, this is the same issue as raised in GitHub <a href="https://github.com/matplotlib/matplotlib/issues/1656" rel="nofollow noreferrer">#1656</a></p>
  
  <pre><code>import datetime as dt
  import matplotlib.pyplot as plt
  import matplotlib.animation as animation
  from random import random
  
  
  class Animate:
  
      def __init__(self, sensor):
          # Create figure for plotting
          self.fig = plt.figure()
          self.ax = self.fig.add_subplot(1, 1, 1)
          self.xs = []
          self.ys = []
          self.ylabel = sensor
          self.readings = 20
  
      # This function is called periodically from FuncAnimation
      def _update(self, i, xs, ys):
  
          # Get sensor value
          value = random()
  
          # Add x and y to lists
          self.xs.append(dt.datetime.now().strftime('%H:%M:%S.%f'))
          self.ys.append(value)
  
          # Limit x and y lists to 20 items
          self.xs = self.xs[-self.readings:]
          self.ys = self.ys[-self.readings:]
  
          # Draw x and y lists
          self.ax.clear()
          self.ax.plot(xs, ys)
  
          # Format plot
          plt.xticks(rotation=45, ha='right')
          plt.subplots_adjust(bottom=0.30)
          plt.title(self.ylabel + ' over Time')
          plt.ylabel(self.ylabel)
  
      def start(self):
          print('Starting')
          # Set up plot to call animate() function periodically
          self.anim = animation.FuncAnimation(self.fig, self._update, fargs=(self.xs, self.ys), interval=200)
          plt.show();
  
  
  rand = Animate('Torque')
  rand.start(); 
  </code></pre>