Hi Monks, I'm trying to get the Chart::Plot module working. I have lots of numerical data in arrays and want to plot this. If I plot the data directly from the arrays I get only a blank graph. However, if i hand-construct the arrays a graph is plotted.

Is there a way of formatting the numbers in my array so that the module can interpret them? (am I missing something?) - obviously i have printed out the contents of the array etc but can't see whats going wrong! I hope someone can help.

# heres my code use strict; use Chart::Plot; open (FILE, $ARGV[0]) or die "Unable to open file: perl says $!"; my $line; my @array; my (@t3, @c3, @a3, @g3, @cai, @cbi, @fop, @nc, @gc3, @gc, @lsym, @laa, + @gravy, @aromo); while (<FILE>) { $line = $_; chomp $line; if ($line !~ /^(\w{2,3})(.{1})(\w{2}\d{6}.{2})(\w?)(\d+\W{1,2} +\d+.{0,5})(\s+)(\d+\W?\d+\s+)(\d+\W?\d+\s+)(\d+\W?\d+\s+)(\d+\W?\d+\s ++)(\d+\W?\d+\s+)(.?\d+\W?\d+\s+)(\d+\W?\d+\s+)(\d+\W?\d+\s+)(\d+\W?\d ++\s+)(\d+\W?\d+\s+)(\d+\s+\d+\s+)(\W?\d+\W?\d+\s+)(\d+\W?\d+)/) { # print "BAD LINE!!!!!!!!!!!!!!!!!!!!!\n"; # print "$line\n"; $line =~ s/.*//; } @array = (); @array = split (/\s+/, $line); # $array[0] to $array[14] should now be defined. $array[1] =~ s/^T3s//; $array[2] =~ s/^C3s//; $array[3] =~ s/^A3s//; $array[4] =~ s/^G3s//; $array[5] =~ s/^CAI//; $array[6] =~ s/^CBI//; $array[7] =~ s/^Fop//; $array[8] =~ s/^Nc//; $array[9] =~ s/^GC3s//; $array[10] =~ s/^GC//; $array[11] =~ s/^L_sym//; $array[12] =~ s/^L_aa//; $array[13] =~ s/^Gravy//; $array[14] =~ s/^Aromo//; push @t3, $array[1]; push @c3, $array[2]; push @a3, $array[3]; push @g3, $array[4]; push @cai, $array[5]; push @cbi, $array[6]; push @fop, $array[7]; push @nc, $array[8]; push @gc3, $array[9]; push @gc, $array[10]; push @lsym, $array[11]; push @laa, $array[12]; push @gravy, $array[13]; push @aromo, $array[14]; } my $gravy = join ('', @gravy); @gravy = split ('', $gravy); print @gravy; my $gc3 = join ('', @gc3); @gc3 = split ('', @gravy); my $graph = Chart::Plot->new (650,400); $graph->setData (\@gravy, \@gc3); my ($x_min,$y_min, $x_max, $y_max) = $graph->getBounds(); $graph->setGraphOptions ('title' => 'My first graph', 'horAxisLabel' => 'gravy', 'vertAxisLabel' => 'gc3'); open (IMG, ">testgraph.png") or die $!; binmode IMG; print IMG $graph->draw(); close IMG;

In reply to Chart::Plot module by Anonymous Monk

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.