The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

GD::Graph::histogram - Histogram plotting module for Perl5

SYNOPSIS

  use GD::Graph::histogram;

DESCRIPTION

GD::Graph::histogram extends the GD::Graph module to create histograms. The module allow creation of count or percentage histograms.

USAGE

Fill an array with all the data values that are to be plotted. Note that GD::Graph::histogram unlike the other GD::Graph modules can only plot one data set at a time.

        $data = [1,5,7,8,9,10,11,3,3,5,5,5,7,2,2];

Create the graph

        my $graph = new GD::Graph::histogram(400,600);

Set graph options

        $graph->set( 
                x_label         => 'X Label',
                y_label         => 'Count',
                title           => 'A Simple Count Histogram Chart',
                x_labels_vertical => 1,
                bar_spacing     => 0,
                shadow_depth    => 1,
                shadowclr       => 'dred',
                transparent     => 0,
        ) 
        or warn $graph->error;

plot the graph

        my $gd = $graph->plot($data) or die $graph->error;

save the graph to a file

        open(IMG, '>histogram.png') or die $!;
        binmode IMG;
        print IMG $gd->png;

METHODS

GD::Graph::histogram supports all the methods support by GD::Graph. Please refer to the GD::Graph documentation for more information.

The only method that behaves differently is plot

The plot method provided by GD::Graph::histogram expects a reference to an array of numbers.

Based on the input data, GD::Graph::histogram will generate the appropriate labels for the X axis. The X axis label represent the center point of the range of each histogram bin.

OPTIONS

GD::Graph::histogram supports all the options supported by GD::Graph::bars. Please refer to the GD::Graph documentation for more information.

The two additional options that are specific to GD::Graph::histogram are:

        histogram_bins
                Specify the number of histogram bins to bucket the data into.
                The default is for the module to automatically computed the
                histogram bins based on the data.

        histogram_type
                Can be set to either 'percentage' or 'count'. By default the module
                will create 'count' histograms.

NOTES

As with all Modules for Perl: Please stick to using the interface. If you try to fiddle too much with knowledge of the internals of this module, you could get burned. I may change them at any time.

AUTHOR

        Snehanshu Shah
        perl@whizdog.com
        http://www.whizdog.com

ACKNOWLEDGEMENTS

Thanks for all the feedback, bug reports and bug fixes

Martin Corley Jonathan Barber William Miller

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

perl(1), GD::Graph