stefan k has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, I have to create about 200 graphics from a perl script that look like this: * 100 datapoints in a black line * 20 datapoints using a red line and having 5percent errorbars round them... * The output format is PNG (or gif, but, please, w/o LZW) I can do that using gnuplot and two files but that takes a long time (esp. since the PNG support seems to be buggy: gnuplot becomes >50MB in memory and needs more than 17 minutes for the job) I already have all the data in a hash of arrays: $data{$number_of_graphic}0...120 and ask you if you know of any tips how to fasten things with perl regards Stefan K

Replies are listed 'Best First'.
Re: Massice Graphic Creation
by btrott (Parson) on Apr 28, 2000 at 20:09 UTC
    Take a look at GD::Graph, which builds on the GD library to provide neat graphing methods. There are a ton of options, so you may be able to find just what you're looking for. It outputs in png, too.
Re: Massive Graphic Creation
by turnstep (Parson) on May 01, 2000 at 18:13 UTC
    PNG is a lot more complicated than GIFs, but then again, it does a lot more. If it is truly rectangular, and these are being output to the web, you can make some very small and very quick-loading GIF images by having perl output an IMG tag to a small GIF, and changing the HEIGHT and WIDTH tags. If not on the web, the GD option mentioned above (thanks btrott!) may be your best bet. But the HEIGHT and WIDTH trick (along with some other HTML tweaking) can produce really nice looking results.
RE: Massive Graphic Creation
by turnstep (Parson) on Apr 29, 2000 at 17:39 UTC
    Could you describe the format of the graphics a little bit better? If they are fairly rectangular, creating the images as gifs directly in perl should not be too hard. Making a png is a bit more complicated, and you'll have to use libpng (in C)
      For legal reasons it should be png (maybe with a little switch to get gifs if people decide to...
      And yes, they are fairly rectangle: it's just a little plot of a timeseries using some additional data for errorbars

      regards StefKa
Re: Massice Graphic Creation
by zaphod.nu (Scribe) on Apr 29, 2000 at 04:04 UTC
    Have you tried running it in debug mode to see if there are any loops that it gets stuck in for a while?

    If you could post the snippet of the script that does the actual image generation so we can check it out we might find something you've missed.
      Oh, it's not in the perl skript, it's gnuplot itself that needs the very loong time. Actually I write a gnuplot script and for testing purpose start gnuplot by hand. Thus I'm looking for several possible solutions: I asked the gnuplot gurus in their newsgroup for help and here at the monks I hope to find a way to do it in perl itself... regards and thanks Stefan K