print IMG $graph1->png; should be
print IMG $gd->png;

You didn't provide any data so I made some up to get a working program :-

#!/usr/bin/perl use strict; use warnings; use GD::Graph::lines; use GD::Graph::colour; GD::Graph::lines->import(); GD::Graph::colour->import(qw(:colours :lists :files :convert)); my @graph_R1 = ([1..50], [1..50], [11..60], [21..70]); my $graph1 = GD::Graph::lines->new(800,600); add_colour(nice_blue => [31,120,180]); $graph1->set( x_label => 'position (bp)', y1_label => '% methylation', y2_label => '# methylation calls', title => 'Mbias plot Read 1', line_width => 2, x_max_value => 125, x_min_value => 0, y_tick_number => 10, y_label_skip => 2, y1_max_value => 100, y1_min_value => 0, y_label_skip => 2, y2_min_value => 0, x_label_skip => 5, x_label_position => 0.5, x_tick_offset => -1, bgclr => 'white', transparent => 0, two_axes => 1, use_axis => [1,1,1,2,2,2], legend_placement => 'RC', legend_spacing => 6, legend_marker_width => 24, legend_marker_height => 18, dclrs => [ qw(nice_blue) ], )or die $graph1->error; $graph1->set_legend('CpG methylation'); my $gd = $graph1->plot(\@graph_R1) or die $graph1->error; open(IMG, '>','test.png') or die $!; binmode IMG; print IMG $gd->png;
poj

In reply to Re: GD graph Invalid data set by poj
in thread GD graph Invalid data set by sramazan

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.