newdata.txt:#!/usr/bin/perl use GD::Graph::lines; use strict; my $i = ""; open(DATA, "newdata.txt") or die "Cannot open for reading: $!\n"; my @newdata = <DATA>; close(DATA); my @graph_data = [ ['May 12', 'May 13'], [], [], [] ]; for($i = 0; $i < scalar($#newdata + 1); $i++) { my ($celcius, $radiation, $time) = split(/ /, $newdata[$i]); $graph_data[1][$i] = $celcius; $graph_data[2][$i] = $radiation; $graph_data[3][$i] = $time; } my $mygraph = GD::Graph::lines->new(600, 300); $mygraph->set( x_label => 'Time', y_label => 'Value', title => 'Temperature and Radiation', x_labels_vertical => 1, x_label_skip => 50, line_types => [1, 1], line_width => 2, dclrs => ['blue', 'green'], ) or warn $mygraph->error; $mygraph->set_legend_font(GD::gdMediumBoldFont); $mygraph->set_legend('Temperature', 'Radiation'); my $myimage = $mygraph->plot(\@graph_data) or die $mygraph->error; open(GRAPH, ">graph.png"); print GRAPH $myimage->png; close(GRAPH);
Man I suck at Perl :/36 85 13:37 36 86 13:38
In reply to Re^2: Help with GD::Graph
by jeiku
in thread Help with GD::Graph
by jeiku
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |