Savefig and StringIO using Agg

Hi,

I am struggling to implement the equivalent of
http://plone.org/documentation/how-to/add-charts to add charting capacilities to
a Plone content type. The example uses PyChart, but I tried replacing the
PyChart code with matplotlib code. Here it is :

...
from cStringIO import StringIO
import matplotlib
matplotlib.use('Agg')
from pylab import *

...

  def MakePlot (self,):

    #imageFile = StringIO()
  
    t = arange(0.0, 2.0, 0.01)
    s = sin(2*pi*t)
    plot(t, s, linewidth=1.0)

    xlabel('time (s)')
    ylabel('voltage (mV)')
    title('Graphique dans Archetypes')
    grid(True)
    savefig("C:\\temp\\test.png")
    fh = open("C:\\temp\\test.png", "rb")
    data = fh.read()
    self.setMyImage(data,mimetype='image/png')
    fh.close()
    clf()
    close("all")

This code works perfectly, but I would like to avoid writing a temp file on the
filesystem, that is savefig(imageFile). Is there a way to use a StringIO object
with savefig ?

Thanx

Yves Moisan