in reply to line graph GD::GRAPH
Update: ishnid's right, the data needs to be grouped by axis, not by point. In his answer, he did miss the bit about your push needing the same unless as your split.
The data needs to be organized into a 2d array. Try changing
push @array, ($x, $y);
to
push @array, [$x, $y];
push @{$array[0]}, $x;
push @{$array[1]}, $y;
Also, I think the first row of the array need to be labels. I'd try adding
@array = (['RT', 'HEIGHT']);
before the while.
You're unless /RT/ needs to be extended to the push.
I'm really just guessing from a glance at the docs. I don't have any experince this module.
open (FH, "<data.txt"); while (<FH>) { chomp; next if /RT/; ($x, $y) = split(/\s+/, $_); push @{$array[0]}, $x; push @{$array[1]}, $y; } my $mygraph = GD::Graph::lines->new(600, 300); $mygraph->set( x_label => 'RT', y_label => 'HEIGHT', title => 'xxx' ); $image = $mygraph->plot(\@array) or die $mygraph->error; open(IMG, '>file2.png') or die $!; binmode IMG; print IMG $image->png; close IMG;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: line graph GD::GRAPH
by ishnid (Monk) on May 19, 2005 at 16:14 UTC | |
by ikegami (Patriarch) on May 19, 2005 at 16:26 UTC |