title: Matplotlib plot in a new thread
body: <p>I am developing a real-time camera application where a new thread is desired for the plotting. A thread class is created for that:</p>
  
  <pre><code># Create new thread for plotting smoothly
  class PlotThread(threading.Thread):
  
      def __init__(self, threadID, fig, ax):
          threading.Thread.__init__(self)
          self.threadID = threadID
          self.fig = fig
          self.ax = ax
          self.h = None
          self.h_raw = None
          self.hr_est = None
  
      def update_data(self, h, h_raw, hr_est):
          self.h = h
          self.h_raw = h_raw
          self.hr_est = hr_est
  
      def run(self):
          self.ax[0].clear()
          self.ax[0].plot(self.h)
          self.ax[0].set_title("Filtered signal")
          self.ax[0].text(150, .002, '%s bpm' % int(self.hr_est), fontsize=18)
          self.ax[0].set_ylim((-0.003, 0.003))
  
          self.ax[1].clear()
          self.ax[1].plot(self.h_raw)
          self.ax[1].set_title("Raw signal")
  
          plt.pause(0.0000000000001)
  </code></pre>
  
  <p>And the main program looks like that:</p>
  
  <pre><code>fig, ax = plt.subplots(2, 1, figsize=(14, 8))
  plt_thread = PlotThread(1, fig, ax)
  
  grabResult = camera.RetrieveResult()
  while camera.IsGrabbing():
      if grabResult.GrabSucceeded():
          # Access the image data
          image = converter.Convert(grabResult)
          frame = image.GetArray()
  
          h, h_raw, hr_est = core.signal_combination(image)
  
          plt_thread.update_data(h, h_raw, hr_est)
          plt_thread.start()
  </code></pre>
  
  <p>In that case the time consuming plot do not terminate the program and the camera can start grabbing the next frame -- resulting in a stable framerate.</p>
  
  <p>I get the following error message:</p>
  
  <pre><code>QObject::setParent: Cannot set parent, new parent is in a different thread
  QObject::setParent: Cannot set parent, new parent is in a different thread
  </code></pre>