hai monks, i have one more clarification on creating graph images, i want ot set heading for the graph which i was create. i tried by this way

print "Content-type: image/png\n\n"; my @data = ([@xaxiss],[@yaxiss]); use GD::Graph::bars; use GD::Image; $width=$xaxiss[0]; $height=$xaxiss[$#xaxiss]; #image -1 graph my $mygraph = GD::Graph::bars->new(800,600); # $mygraph->set_legend('Show gene details'); $mygraph->set( title => "$pairs[0]", x_label => "@xaxis", x_labels_vertical => 90, bar_width => 10, bar_spacing => 1, show_values => 1, dclrs => ['lorange'] , axislabelclr => 'red', # logo => 'bgcolor1.png', /corect on/ # logo_resize =>5.5, transparent => 1, shadowclr => 'gray', shadow_depth =>3, borderclr=>'green', transparent => '0', bgclr => 'lbrown', boxclr => 'lbrown', fgclr => 'blue', cycle_clrs => '1', ) or warn $mygraph->error; $mygraph->set_title_font(GD::gdGiantFont); #$mygraph->set_legend_font(GD::gdGiantFont); $mygraph->set_x_axis_font(GD::gdMediumBoldFont); $mygraph->set_y_axis_font(GD::gdMediumBoldFont); $mygraph->set_values_font(GD::gdSmallFont); my $myimage = $mygraph->plot(\@data) or die $mygraph->error; open(OUT,">/tmp/img1.png"); binmode OUT; print OUT $myimage->png; close OUT; &head_1; print $myimage->png; #image-2 for heading sub head_1{ sub InitColors { my($im) = $_[0]; # Allocate colors $white = $im->colorAllocate(255,255,255); $black = $im->colorAllocate(0,0,0); $red = $im->colorAllocate(255,0,0); $blue = $im->colorAllocate(0,0,255); $green = $im->colorAllocate(0, 255, 0); $brown = $im->colorAllocate(255, 0x99, 0); $violet = $im->colorAllocate(255, 0, 255); $yellow = $im->colorAllocate(255, 255, 0); } use GD; # Create a new image $im = new GD::Image(500, 80); # Allocate some colors &InitColors($im); # Make the background transparent and interlaced $im->transparent($white); $im->interlaced('true'); $im->rectangle(0, 0, 500, 79, $white); $x1 = 10; $y1 = 20; # Draw text in a TTF font # $font = "/usr/X11R6/lib/X11/fonts/TTF/luxisri.ttf"; # $im->stringFT($red, $font, 15, 0, $x1, $y1, "A TTF font"); #$anotherfont = "/usr/share/fonts/default/TrueType/starbats.ttf"; $anotherfont = "/usr/share/fonts/ko/TrueType/hline.ttf"; $im->stringFT($black, $anotherfont, 30, 0, $x1, $y1 + 40, "Show gene d +etails"); # Open a file for writing open(PICTURE, ">/tmp/picture.png") or die("Cannot open file for writin +g"); # Make sure we are writing to a binary stream #binmode PICTURE; # Convert the image to PNG and print it to the file PICTURE #print PICTURE $im->png; print $im->png; close PICTURE; }

in the above code the first image-1 indicate the bar chart generated for the data and the second one image-2 which is called by using subroutine is the heading for that graph, but while using this method only one image is displaying on the screen, is their any sugession for this or any different idea on about it.

------------------------------------------------------

hi monks, i tried to make the two separate images as single image by changing the code as follows is it correct.

--new code-- print "Content-type: image/png\n\n"; sub InitColors { my($im) = $_[0]; # Allocate colors $white = $im->colorAllocate(255,255,255); $black = $im->colorAllocate(0,0,0); $red = $im->colorAllocate(255,0,0); $blue = $im->colorAllocate(0,0,255); $green = $im->colorAllocate(0, 255, 0); $brown = $im->colorAllocate(255, 0x99, 0); $violet = $im->colorAllocate(255, 0, 255); $yellow = $im->colorAllocate(255, 255, 0); } my @data = ([@xaxiss],[@yaxiss]); use GD::Graph::bars; use GD::Image; $width=$xaxiss[0]; $height=$xaxiss[$#xaxiss]; #image -1 graph my $mygraph = GD::Graph::bars->new(800,600); $mygraph->set_legend('Show gene details'); --changed portion-- $anotherfont = "/usr/share/fonts/ko/TrueType/hline.ttf"; $mygraph->set_stringFT('black', $anotherfont, 30,40, "Show gene detail +s"); ---change ends--- $mygraph->set( title => "$pairs[0]", x_label => "@xaxis", x_labels_vertical => 90, bar_width => 10, bar_spacing => 1, show_values => 1, dclrs => ['lorange'] , axislabelclr => 'red', # logo => 'bgcolor1.png', /corect on/ # logo_resize =>5.5, transparent => 1, shadowclr => 'gray', shadow_depth =>3, borderclr=>'green', transparent => '0', bgclr => 'lbrown', boxclr => 'lbrown', fgclr => 'blue', cycle_clrs => '1', ) or warn $mygraph->error; $mygraph->set_title_font(GD::gdGiantFont); #$mygraph->set_legend_font(GD::gdGiantFont); $mygraph->set_x_axis_font(GD::gdMediumBoldFont); $mygraph->set_y_axis_font(GD::gdMediumBoldFont); $mygraph->set_values_font(GD::gdSmallFont); my $myimage = $mygraph->plot(\@data) or die $mygraph->error; #open(OUT,">/tmp/img1.png"); #binmode OUT; #print OUT $myimage->png; #close OUT; print $myimage->png;

while compiling this code it show the error message as follows,
--Error code-- http://10.188.12.27/cgi-bin/msgs/siva_graph/ graph1cgi.pl?A_thaliana&2&1&7473&NC_003070sNC_003071&6973s4403&
by sanku thanks in advance any sugessions please?????

In reply to Using an image as a header with GD::Graph by sanku

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.