http://qs321.pair.com?node_id=565126

There is one important instance where GD::Graph::lines does not suffice. That is the case where you require two Y axes (left & right) with more than two data curves to trace.

So I have cobbled together a module (my first ever OO) which covers that instance where GD::Graph::lines is lacking. May it serve as a tide-over until the day (month?, year?) when GD::Graph::lines shall be repaired.

This is a self-actualizing demo of the module, part of a utility I'm working on to graph strain gage rosette data. It generates fake data, saves it to a file, reads it back in, adds some calcualted-result channels, graphs it both in GD as *.png and in PostScript as an *.eps file

That's right, the output is PostScript. So you'll need a viewer (gv on UNIX, GSView on Win32) to view it. Running the file also calls up whichever of those is appropriate for your OS to display the graph.

It only does line graphs but does them quite prettily...except for the example given...which is deliberately hideous to show off user options for colors, fonts, etc. (I'm not really color-blind.)

Graphing Module Demo

There isn't any real Perl magic here, though. It's PostScript which performs all the tricks. I dredged up an old standalone PostScript graphing program which I'd written way back in 1992, tidied it a bit, broke it into pieces and married those pieces to Perl to make this happen.

You can choose any web safe color for back- and fore-grounds, lines, etc. You can choose any of the 35 fonts. And it auto-reconciles the Y1 and Y2 axes for best resolution of the data traces. That is to say, for each axis, at least one trace will course nearly the whole vertical area.

Its one big flaw is that no single data trace may number more than 65,535 data points. This is due to PostScript's internal addressing limitation...which I have yet to creatively overcome. At some point later on, after I've tinkered with it a bit more, I'll put in in CPAN. For now it's embeded in the demo script.

Gan Uesli Starling
Kalamazoo MI USA