Savefig and StringIO using Agg


I am struggling to implement the equivalent of 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
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')
    fh = open("C:\\temp\\test.png", "rb")
    data =

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 ?


Yves Moisan