You need to transpose your @point array so that $point[0] is the series of times and $point[1] is the series of fees

push @{$point[0]},$timer; push @{$point[1]},$fee;

try

#!/usr/bin/perl use warnings ; use strict ; use GD::Graph::linespoints ; my %position = ( 'a' => [0,0] , 'b' => [1,0] , 'c' => [2,0] , 'd' => [0,1] , 'e' => [1,1] , 'f' => [2,1] , 'g' => [0,2] , 'h' => [1,2] , 'i' => [0,3] , 'k' => [1,3] , 'l' => [2,3] , ) ; my @p = keys %position ; my @point ; my $timer = 0 ; for my $request (0..179) { my $pdirty = $p[int rand @p] ; my $pvacum = $p[int rand @p] ; my $fee = 0; if ($pvacum eq $pdirty) { print 'Fee is Zero' , "\n" ; } else { my @p2 = @{$position{$pdirty}} ; my @p1 = @{$position{$pvacum}} ; $fee = 2 * (abs (($p2[0] - $p1[0]) + ($p2[1] - $p1[1]))) ; } $timer = $timer + $fee + 2 ; push @{$point[0]},$timer; push @{$point[1]},$fee; print "$request\t$timer\t$fee\n" ; } my $graph = new GD::Graph::linespoints(1000 , 500) ; $graph->set( x_label => 'Time' , x_label_skip => 5, y_label => 'Fee' , title => 'Time Vs Fee') or warn $graph->error ; $graph->plot(\@point); open OUT,'>','image.jpeg' or die "$!"; binmode OUT; print OUT $graph->gd->jpeg;
poj

In reply to Re: print a graph by poj
in thread print a graph by GHMON

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.