krish28 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,
I am trying to use the GD::Graph::Histogram module in this code here, to plot counts at locations:
my $graph = new GD::Graph::histogram(4000000,6000000); $graph -> set( x_label => 'Location', y_label => 'Count', title => 'Sample Histogram', x_labels_vertical => 1, bar_spacing => 0, shadow_depth => 1, shadowclr => 'dred', transparent => 0, ) or warn $graph -> error; my $gd = $graph -> plot (\@arrayofinterest) or die $graph->error; open (IMG, '>histo.png') or die $!; binmode IMG; print IMG $gd -> png;
But its not working and i get this error message when i try to run it:
Not a GD::Image object at /usr/lib/perl5/site_perl/5.8.5/GD/Graph.pm l +ine 180
Can anyone help?
I've installed GD, GD::Graph and the GD::Graph::Histogram modules, but to no avail!!
Thanks
Krish

Replies are listed 'Best First'.
Re: problem using GD::Graph::Histogram
by zwon (Abbot) on Jan 14, 2010 at 22:56 UTC

    Are you sure you have enough RAM for 4000000x6000000 pixels image? ;)

Re: problem using GD::Graph::Histogram
by Khen1950fx (Canon) on Jan 15, 2010 at 19:37 UTC
    I noticed two things: The data set "\@arrayofinterest" probably won't work the way that you think. Also, look back at the sample and look at the data set that the author gave. I tried the sample, and it worked fine. It prints the png to the home directory. Here's the sample:
    #!/usr/bin/perl use strict; use warnings; use GD::Graph::histogram; my $data = [1,5,7,8,9,10,11,3,3,5,5,5,7,2,2]; my $graph = new GD::Graph::histogram(400,600); $graph -> set( x_label => 'Location', y_label => 'Count', title => 'Sample Histogram', x_labels_vertical => 1, bar_spacing => 0, shadow_depth => 1, shadowclr => 'dred', transparent => 0, ) or warn $graph->error; my $gd = $graph->plot($data) or die $graph->error; open (IMG, '>histo.png') or die $!; binmode IMG; print IMG $gd->png;
      Hi Khen,
      Thanks for the reply. I was planning on using the sample code, but i noticed that the variable "$data" is defined as an array, or thats what my limited knowledge of perl led me to believe..I don't know abt this data type yet..
      So i used the sample code as i saw in the GD::Graph module!!
      I'll try this sample code!!
      Krish