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
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 $!;
print IMG $gd->png;
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.