title: Renderer problems using Matplotlib from within a script
body: <p>I've narrowed down to this call:</p>
  
  <pre><code>fig.canvas.tostring_argb() #fig=matplotlib.pyplot.figure()
  </code></pre>
  
  <p>this function raises an <code>AttributeError</code> when I run the code as a python script.
  <code>AttributeError: 'FigureCanvasGTKAgg' object has no attribute 'renderer'</code></p>
  
  <p>However, this code works properly if run in the <code>ipython --pylab</code> command line.</p>
  
  <p>As far as I can tell from the documentation, the Agg renderer should work OK.</p>
  
  <p>The context is that I'm trying to make a movie from figures, without saving the frames
  to disk; as per <a href="https://stackoverflow.com/questions/4092927/generating-movie-from-python-without-saving-individual-frames-to-files">this question</a>.  I'm using the approach that streams the pixel arrays 
  to <code>ffmpeg</code> (running as a separate  process) to do this, I need the <code>argb</code> array of values from the frame.</p>
  
  <p>Is there some configuration setting I can make to get matplotlib to work correctly from within a script?</p>
  
  <p><em>Edit</em> 
  Tried <code>use('Agg')</code> as per a comment; still fails;  this is a minimal working example.</p>
  
  <pre><code>[dave@dave tools]$ python -c "import matplotlib; matplotlib.use('Agg'); import matplotlib.pyplot; fig=matplotlib.pyplot.figure(); fig.canvas.tostring_argb()"
  Traceback (most recent call last):
    File "&lt;string&gt;", line 1, in &lt;module&gt;
    File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 416, in tostring_argb
      return self.renderer.tostring_argb()
  AttributeError: FigureCanvasAgg instance has no attribute 'renderer'
  </code></pre>