Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#script for table of summarized results for whole dataset use GD::Graph::bars; use GD::Graph::hbars; @methods=(); #keeps methods' names @data=(); #keeps all data @all=(); #keeps everything open IN, $ARGV[0]; while (<IN>) { chomp $_; if($_=~/^METHOD\t(.*)/) #1st line is the Header line { $header_all = $1; @split_header = split(/\t/, $header_all); } else { $method_line = $_; #lines with the methods @split_method = split(/\t/, $method_line); $method_name= shift (@split_method); push @methods, $method_name; push @data, @split_method; } } close IN; @all = ( @methods, @data); $legend = "@methods"; $name = "TEST"; $my_graph = GD::Graph::bars->new; $my_graph->set( #x_label => 'X Label', #y_label => 'Y label', #title => 'Stacked Bars (incremental)', #y_max_value => 50, #y_tick_number => 10, #y_label_skip => 2, cumulate => 2, borderclrs => $my_graph->{dclrs}, #cycle_clrs => 2, bar_spacing => 4, #shadow_depth => 4, transparent => 0, ); $my_graph->set_legend(@split_methods); $my_graph->plot(\@all); save_chart($my_graph, $name); sub save_chart { $chart = shift or die "Need a chart!"; $name = shift or die "Need a name!"; local(*OUT); $ext = 'png'; open(OUT, ">$name.$ext") or die "Cannot open $name.$ext for write: $!"; binmode OUT; print OUT $chart->gd->$ext(); close OUT; }
|
|---|