Thanks for the replies! Hmmm, not sure what I'm doing wrong now.. I tried that but the graph is kinda screwed.
#!/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);
newdata.txt:
36 85 13:37 36 86 13:38
Man I suck at Perl :/

In reply to Re^2: Help with GD::Graph by jeiku
in thread Help with GD::Graph by jeiku

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.