Dear Master Monks,

I have not made a lot of graphing scripts, so I humbly ask your advice.

How would I change the following (I cant find the right info in the docs):

  1. Switch the y-axis round, so that the lowest number is at the top
  2. Change the square dot to an X, at the value points
  3. Add the actual time value to the top of the square/X

Code:

#!/usr/bin/perl use strict; use warnings; # running-times 15-05-05 # # Graphing all my running times. # I will just insert the data # directly into this program for now, # but when it becomes too much, Ill # move it into another file/dbm use GD::Graph::linespoints; use Getopt::Std; my %times; # running times my $chart; # the GD::Graph::linespoints object my $plot; # the GD object containing the actual graph my @DAYS = qw(Mon Tue Wed Thu Fri Sat Sun); # process options my %Opt; getopts('ho:', \%Opt); if ($Opt{h} or !$Opt{o}) { die "Usage:\n\t$0 -o outfile.png \n"; } # Running times %times = ( "Mon" => "25.40", "Tue" => "24.20", "Wed" => "22.50", "Thu" => "23.30", "Fri" => "21.10", "Sat" => "24.30", "Sun" => "25.19", ); # build graph $chart = GD::Graph::linespoints->new(480,320); $chart->set(x_label => "Day", y_label => "Time (mins)", title => "Running Times for 5km - W/E May 15th 2005"); $plot = $chart->plot([ [ @DAYS ], [ @times{@DAYS} ], ]); # save it open(F, "> $Opt{o}") or die "Can't open $Opt{o} for writing: $!\n"; print F $plot->png; close F; # Create html page with png in it open H, ">times.html" or die "Can not create webpage: $!\n"; use CGI; my $query = CGI->new( ); print H $query->start_html(-title=>'Gavins Weekly Running Times'); print H $query->p("Here are your times:"); print H "<table><tr><td><img src=$Opt{o}></a></td></tr></table>"; print H $query->end_html( ); close H;

Thanks,
Gavin.

Walking the road to enlightenment... I found a penguin and a camel on the way.....
Fancy a yourname@perl.me.uk? Just ask!!!

In reply to GD::Graph::linespoints - Various questions by ghenry

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.