For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > October 2004 > GD::Graph - how to get rid of leading gap in line graph?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author GD::Graph - how to get rid of leading gap in line graph?
carcassone_fr@yahoo.com

2004-10-02, 8:57 am

Is there a way to get rid of the leading gap to the left of a line
graph? Therefore, I want the graph line to start on the Y-axis, not
the position of the first X tick. Or, make the first X tick be
located on the Y-axis.

Here is a simple example:

#!/usr/local/bin/perl
use strict;
use GD;
use GD::Graph::lines;

my @months = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" );
my @rainfall = ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 );
my @array = (\@months, \@rainfall);

my $graph = new GD::Graph::lines(768, 896);
$graph->set( y_long_ticks => "1", x_tick_offset => "2" );

my $gd_image = $graph->plot( \@array );
open(IMG, ">./test.png") or die $!;
binmode IMG;
print IMG $gd_image->png;

exit 0;

This graph will have a gap between the Y-axis and the first X tick
"Jan".

Thanks in advance for your help.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com