#!perl use GD::Graph::bars; use GD::Graph::hbars; my @data = ( ['Mar1','Mar2','Apr1','Apr2','May1','May2'], [1,0,2,0,4,0], [2,0,1,0,5,0], [0,3,0,3,0,6], [0,4,0,4,0,7], ); my @names = qw/sample15 sample15-h/; for my $my_graph (GD::Graph::bars->new, GD::Graph::hbars->new) { my $name = shift @names; print STDERR "Processing $name\n"; $my_graph->set( x_label => 'X Label', y_label => 'Y label', title => 'Stacked Bars (incremental)', cumulate => 1, overwrite => 1, borderclrs => $my_graph->{dclrs}, bar_spacing => 5, transparent => 0, ); $my_graph->set_legend( qw(A B C D)); my $gd = $my_graph->plot(\@data); open(IMG, '>',$name.'.gif') or die $!; binmode IMG; print IMG $gd->gif; close IMG; }