title: Python Matplotlib: How to use non-gui and gui backend in one program?
body: <p>Hey I spend a good amount at google but couldn't find a solution for this:</p>
  
  <p>I'm plotting a graph embededded in a pygame window using a non-gui-backend:</p>
  
  <pre><code>import matplotlib as mpl
  mpl.use("Agg")
  
  import matplotlib.backends.backend_agg as agg
  import matplotlib.pyplot as plt
  
  fig = plt.figure(num=3, figsize=[3.5, 2.6], # Inches
                  dpi=100,        # 100 dots per inch, so the resulting buffer is 400x400 pixels
                  )
  x = [1,2,3]
  y = [1,2,3]
  
  ax = fig.gca()
  plt.step(x, y, 'r')
  
  canvas = agg.FigureCanvasAgg(fig)
  canvas.draw()
  renderer = canvas.get_renderer()
  raw_data = renderer.tostring_rgb()
  
  screen = pygame.display.get_surface()
  
  size = canvas.get_width_height()
  
  surf = pygame.image.fromstring(raw_data, size, "RGB")
  screen.blit(surf, (0,pictureSize_y))
  </code></pre>
  
  <p>Now I want to create a new window plotting different data. I always get the Error:</p>
  
  <blockquote>
    <p>UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure</p>
  </blockquote>
  
  <p>I tried it with <a href="https://stackoverflow.com/questions/3285193/how-to-switch-backends-in-matplotlib-python">this Post</a> which leads to this:</p>
  
  <blockquote>
    <p>RuntimeError: main thread is not in main loop</p>
  </blockquote>
  
  <p>So ist there any way to use both?</p>