Rendering a plot into a variable?

    imbuf = StringIO() im = Image.fromstring('RGB', (width,

    > height), buf, 'raw', 'RGB', 0, 1) im.save(imbuf, 'PNG')
    > return imbuf.getvalue()

Note to enterprising mpl users/developers, we should take a look at
the PIL code to see how the effbot does this. I have spent some time
looking into libpng to see how to get it to write to a StringIO
instance. Last time I looked, I couldn't find a way to get a FILE*
out of the stringio instance.... The ability to write to a StringIO
instance is a frequent reqest, and emulating PILs approach would be a
good way to go (and faster than Ken's approach).

JDH