[I only seem to be getting this message from the list today, despite the 
timestamp of 2007-12-05.  Sorry for the delay.]

As of matplotlib 0.91.1, savefig() supports saving to a file-like object 
for most backends (excluding Gtk and Wx).  You can pass in a StringIO 
object to savefig for instance, and then pass its content to the XML 
parser of your choice.  (There is no way to get DOM objects directly, 
since the SVG backend actually writes the XML content directly as a 
stream of bytes).

You can specify SVG as your output by either setting the backend 
appropriately or passing a "format" kwarg to savfig, e.g.

   savefig(fileobj, format="svg")

Cheers,
Mike

bplewe wrote:
> [Fairly new at matplotlib, but very happy with it so far]
> 
> Is it possible to retrieve images rendered by one of the backends as an
> object, rather than just saving to a file?  
> 
> Specifically, I need to render graphs to SVG code, that I can turn into a
> DOM object for further manipulation.  I can save to a temp file and
> immediately reload it into a DOM, but that is cumbersome in a single
> program.
> 
> The only place I can see to generate rendered output is savefig().  There is
> a reference in the documentation to using a file-like object with the Cairo
> backend.  Is that the only possibility?
> 
> If so, any ideas on a workaround other than temp files?

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to