Hi Monks,
I'm trying to use Chart::plot to make a simple scatter graph.
This works for test data that i've made up but doesn't work for my actual data. I've tested that both @x and @y contain the same number of elements and they both contain numbers. Can anyone see why this isn't working?
Cheers!
# @filtered_option1 and 2 look like this: 0.4025 -0.606897 -0.158242
+0.2025 -0.24058 0.131667 -0.085 -1.1234 -0.093793 -0.458974 0.360345
+-0.420438 0.060759 -0.183562 -0.726804 0.867273 -0.41 -0.391667 -0.02
+4828 -0.410113 0.263917 -0.746429 -0.068269 -0.455814
### IT WORKS FOR THESE BELOW!!
#my @x = ("0.4025" ,"-0.606897", "-0.158242" ,"0.2025", "-0.24058", "0
+.131667", "-0.085", "-1.1234");
#my @y = ("0.4025" ,"-0.606897", "-0.158242" ,"0.2025", "-0.24058", "0
+.131667", "-0.085", "-1.1234");
+
+
+
+
+
my @x = @filtered_option1;
my @y = @filtered_option2;
+
+
my $x = @x;
my $y = @y;
# TO CHECK THAT THEY HAVE THE SAME NUM ELEMENTS
print "x is $x y is $y\n";
+
+
+
+
my $img = Chart::Plot->new(450,450);
+
+
$img->setData(\@x, \@y);
$img->setGraphOptions (_title => 'My graph');
open (WR,'>plot.png') or die ("Failed to write file: $!");
binmode WR; # for DOSish platforms
print WR $img->draw();
close WR;
print qq(<img src=\"plot.png\" width=450 height=450>);
+
+
+
+
+
# PLOTS THE AXIS BUT NO DATA-POINTS
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.