Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
my @data = split /\n/, $data; $data[2] =~ s/,/\t/g; my @temps = $data[2]; my $temps = join ('', @temps); @temps = split (/\s+/, $temps); shift @temps; foreach my $line (@file) { @new = (); push (@new, $+) while $line =~ m { "([^\"\\]*(?:\\.[^\"\\]*)*)",? | ([^,]+),? |, }gx; push (@new, undef) if substr ($line, -1,1) eq ','; join('', split(/(?=\w)/, @new)); shift @new; # printing @temps and @new here prints different values for e +ach line (of @new) # prints same graph each time my $plot = plot_graph (\@temps, \@new); print qq(<img src=$plot>); } sub plot_graph { my ($temps, $numbers) = @_; my @graph_data = (\@$temps, \@$numbers); my $graph = GD::Graph::lines ->new (600,600); $graph->set( x_label => 'Temperature degrees C', y_label => 'Fluorescence Derivative', x_max_value =>95, y_max_value =>0.7, x_label_position =>1/2, x_tick_number =>20, y_tick_number =>10 ) or die $graph->error; $graph->set (dclrs=> [qw(green red blue)]); my $gb = $graph->plot(\@graph_data) or die $graph- +>error; open (IMG , ">temp/$$.png") or die $!; binmode IMG; print IMG $gb->png; close IMG; my $plot = "temp/$$.png"; return $plot; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: loops + creating graphs
by BrowserUk (Patriarch) on May 28, 2003 at 16:22 UTC | |
by Anonymous Monk on May 28, 2003 at 16:24 UTC | |
by BrowserUk (Patriarch) on May 28, 2003 at 16:52 UTC | |
by wufnik (Friar) on May 28, 2003 at 16:58 UTC |