John,
I'm cc'ing the gnuplot-py-users mailing list...
[The original question was whether it is practical to use Gnuplot.py to
generate graphics in a web server.]
John Draper wrote:
>>Hello,
>>
>>Sure, gnuplot + Gnuplot.py can do that.
>>
>>I would suggest you get the latest CVS version of Gnuplot.py; then you
>>can do something like
>>
>> g = Gnuplot.Gnuplot()
>> ips = list of 4-tuples of ip octets from your database like
>>[(192,168,1,1), (198,137,240,92),...]
>> g.title('Spam sources')
>> g.xlabel('First octet')
>> g.ylabel('Second octet')
>> g.plot(ips, cols=(0,1), with='dots')
>> g.hardcopy('file.png', terminal='png', fontsize='large', color=1)
>>
>>This writes the output to a file called "file.png" in the current
>>directory. Then you just need to get your web server to insert the
>>image into the web page and somehow arrange for old files to be cleaned
>>up once in a while.
>>
>>
>
>Wow - most excellent.
>
>
>>Through some more magic it would be possible to create the output on the
>>fly and pump it straight to the client, but that's a little bit
>>trickier.
>>
>>
>
>Yes- I'm going to need to know how to do that. So, when you say "trickier" what do you mean by that.
>
>
It might be possible (I'm not sure) to have gnuplot write its png output
to stdout by using g("set term png ...") before generating the original
plot. I'm not sure if gnuplot outputs other stuff on standard out that
would confuse the output.
Another alternative would be to create a named pipe and have gnuplot
write its output to that "file". Another thread or process could
capture the output and pump it out of the web server.
>>It should also be possible to omit the initial output to the
>>monitor but I haven't tried that before.
>>
>>
>
>I have no "monitor" as there is no graphical device on the server at all.
>
Well then you would want to g("set term png [...]") before creating the
initial plot. It means you can't use the hardcopy() method (at least
not without first making some minor changes) but that's not such a problem.
Michael
--
Michael Haggerty
mh...@al...
|