title: How can I update my data in matplotlib.Funcanimation using a variable from another process using multiprocessing manager in Python?
body: <p>Basically what I want to do is draw a graph in real-time that updates/animates the data that is being shared across multiple processes. I have used Manager from the python multiprocessing module and shared a <code>wave</code> list (that is an array) that is updated/modified in another process in a <strong>while loop</strong>. </p>
  
  <p>It seems that when I run the FuncAnimation function I can only update the data displayed according to local or global variables within the same process. Here is my code:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  from matplotlib.animation import FuncAnimation
  
  x = np.arange(0, 4408)
  wave = np.arange(0, 4408)
  
  def animate(i):
      plt.cla()
      global x
      x = [a + 4408 for a in x] # x-axis continues to shift
  
      plt.plot(x, wave)
  
  # wave array from another process
  def graph(shared_wave):
      global wave
      wave = shared_wave # Here it gets updated once but never again
      ani = FuncAnimation(plt.gcf(), animate, interval=100)
      plt.tight_layout()
      plt.show()
  </code></pre>
  
  <p>Any help would be greatly appreciated. One thing I have been thinking about is using multithreading in one process to run the animation in one thread and another thread to update a global variable.</p>