title: matplot camera animation warning animation deleted
body: <p>i am trying to make a animation of gradient descent and i see no error with code but the result is warning saying that the animation has been deleted. here is my full code</p>
  <pre><code>import pandas as pd
  import numpy as np
  import matplotlib.pyplot as plt
  import pymysql
  from celluloid import Camera
  
  def load_dbscore_data():
      conn = pymysql.connect(host='localhost', user='root', password='1234', db='score')
      curs = conn.cursor(pymysql.cursors.DictCursor)
  
      sql = &quot;select * from score&quot;
      curs.execute(sql)
  
      data = curs.fetchall()
  
      curs.close()
      conn.close()
  
      X = [(t['final']) for t in data]
      X = np.array(X)
  
      y = [(t['score']) for t in data]
      y = np.array(y)
  
      return X, y
  
  
  X, y = load_dbscore_data()
  
  fig = plt.figure()
  camera = Camera(fig)
  
  epochs = 100000
  min_grad = 0.0001
  learning_rate = 0.001
  
  m = 0.0
  c = 0.0
  
  n = len(y)
  
  c_grad = 0.0
  m_grad = 0.0
  
  for epoch in range(epochs):
  
      for i in range(n):
          y_pred = m * X[i] + c
          m_grad += 2 * (y_pred - y[i]) * X[i]
          c_grad += 2 * (y_pred - y[i])
  
      c_grad /= n
      m_grad /= n
  
      m = m - learning_rate * m_grad
      c = c - learning_rate * c_grad
  
  
  
      if (epoch % 1000 == 0):
          print(&quot;epoch %d: m_grad=%f, c_grad=%f, m=%f, c=%f&quot; % (epoch, m_grad, c_grad, m, c))
          plt.plot([min(X), max(X)], [m * min(X) + c, m * max(X) + c], color='red')
          camera.snap()
  
      if (abs(m_grad) &lt; min_grad and abs(c_grad) &lt; min_grad):
          break
  
  animation = camera.animate()
  </code></pre>
  <p>for this code i have result</p>
  <p>UserWarning: Animation was deleted without rendering anything. This is most likely unintended. To prevent deletion, assign the Animation to a variable that exists for as long as you need the Animation.</p>
  <p>what is the problem?</p>