my $graph = new GD::Graph::histogram(600,600); $graph->set( x_label => 'Date and Time', y_label => 'Messages', title => 'Number of messages per bin', x_labels_vertical => 1, bar_spacing => 0, shadow_depth => 0, transparent => 0, histogram_bins => 10, show_values => 1, x_number_format => \&x_format, x_tick_number => 10, ); sub x_format { my $value = shift; # print $value . " " . localtime(int($value)) . " " . strftime( "%Y-%m-%d %H:%M:%S", localtime(int($value))) . "\n"; # test return strftime( "%Y-%m-%d %H:%M:%S", localtime(int($value))); } my $timevalues_ref = \@timevalues_secs; my $IMG; open($IMG, '> test_plot.png'); binmode $IMG; print $IMG $graph->plot($timevalues_ref)->png; close ($IMG);