From: John H. <jdh...@ac...> - 2005-08-31 14:16:42
|
>>>>> "Robert" == Robert Kern <rk...@uc...> writes: Sascha> I am writing a web server app that creates charts among Sascha> other things. I am trying to get rid of the temporary file Sascha> that I use to transmit the figures created with matplotlib Sascha> to the actual web server. Although print_figure says "If Sascha> filename is a fileobject, write png to file object (thus Sascha> you can, for example, write the png to stdout)" I can't Sascha> successfully write anything to stdout. Anyone knows an Sascha> example or can give me some hint what I can do to get rid Sascha> of the tempfile? >> Short answer: no known way to do this currently, though we'd >> like to figure it out. As far as I know (and could very well >> be wrong) libpng requires a FILE*, which StringIO and cStringIO >> do not provide. Robert> StringIO isn't the issue here; being able to write to Robert> sys.stdout, which ought to have a valid FILE* underneath, Robert> is the issue. Thanks for reminding me about this. I thought it was possible to do this, but had managed to forget import sys from pylab import plot, savefig, show plot([1,2,3]) savefig(sys.stdout) show() which I run with > python test.py -dAgg > test.png produces the expected figure. JDH |