"bgclr => 'white'," is not honored once the text::wrap module is used to place a textbox into my graph. The background turns black. It works ok when Graph::linespoints is a stand alone. Any Ideas?
#!/usr/bin/perl -w use CGI; use GD; use GD::Graph::linespoints; use GD::Text::Wrap; use strict; # +++++++++ Now to plot the results! +++++++++++ # Both the arrays should same number of entries. my @data = ([-12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1 +, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [0, 143, 27, 34, 26, 44, 48, 117, 282, 771, 1425, 1862, +1952, 1520, 913, 567, 285, 162, 93, 71, 39, 21, 21, 46, 0], [0, 0, 0, 30, 33, 59, 143, 299, 671, 1299, 1851, 1968, 1 +663, 1097, 648, 325, 182, 99, 50, 40, 20, 39, 0, 0, 0]); my $avg1_Graph = -2.62; my $stddev1_Graph = 30.76; my $avg2_Graph = -9.35; my $stddev2_Graph = 24.74; my $infile1 = 'h5_residual_7590_before.txt'; my $infile2 = 'h5_residual_7590_after.txt'; my $graph = GD::Graph::linespoints->new(750, 500); $graph->set_title_font(GD::gdGiantFont); $graph->set_x_label_font(GD::gdGiantFont); $graph->set_y_label_font(GD::gdGiantFont); $graph->set_values_font(GD::gdMediumBoldFont); $graph->set( title => 'Residual Distribution Pre & Post Tomography', x_label => 'Residual/10', x_label_position => 0.5, y_label => 'Count', line_types => [1, 1], line_width => 2, markers => [7, 7], marker_size => 4, long_ticks => 1, dclrs => ['blue', 'red'], bgclr => 'white', fgclr => 'lgreen', box_axis => 0, legend_placement => 'BC', legend_marker_width => 12, legend_marker_height => 12 ) or warn $graph->error; $graph->set_legend_font(GD::gdMediumBoldFont); $graph->set_legend("Before Tomo", "After Tomo"); my $gd = $graph->plot(\@data) or die $graph->error; my $img_tmp = "img_tmp.png"; open FILE, ">$img_tmp"; binmode FILE; print FILE $gd->png; close FILE; my $gd_image = GD::Image->newFromPng($img_tmp) ; # my $ivory = $gd_image->colorAllocate(255, 255, 240); my $black = $gd_image->colorAllocate(0, 0, 0); my $lgreen = $gd_image->colorAllocate(0, 255, 0); my $text = <<EOSTR; $infile1\n $infile2\n Before Tomo\n Avg: $avg1_Graph\n Std Dev: $stddev1_Graph\n After Tomo\n Avg: $avg2_Graph\n Std Dev: $stddev2_Graph\n EOSTR my $wrapbox = GD::Text::Wrap->new( $gd_image, line_space => 4, color => $lgreen, text => $text, ); $wrapbox->set(align => 'left', width => 175); $wrapbox->draw(510,150); $gd_image->rectangle($wrapbox->get_bounds(505,150), $lgreen); open FILE, ">img.png"; binmode FILE; print FILE $gd_image->png;
In reply to "bgclr" attribute not being recognized while using GD::graph::linespoints and GD::text::wrap by gbs1142
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |