Because it's Perl, I think I may try another shot (semi-golf version):

use Imager; my ($n, $fac) = (40, 10); # 2D-SIZE, FACTOR TO IMAGE my $fn = shift || 'datafile.dat'; open my $fh, '<', $fn or die "$fn $!"; # OPEN FILE my $img = Imager->new(xsize=>$n*$fac, ysize=>$n*$fac, channels=>3); $img->box(filled=>1, color=>'#FFFFFF'); # BACKGROUND $img->box(color=>[($_->[2]/10)*25, $_->[2]*2.5, $_->[2] ], filled=>1, xmax=>($_->[0]+1)*$fac, ymax=>($_->[1]+1)*$fac, xmin=>$_->[0]*$fac, ymin=>$_->[1]*$fac) for map [split /\s+ +/], <$fh>; $img->write(file=>'my.jpg', jpegquality=>90) or die $img->errstr;

the 2D matrix storage is't really necessary, this can be handled in "mid-air" ...

Regards

mwa


In reply to Re^2: matrix 'graphic' problem by mwah
in thread matrix 'graphic' problem by Angharad

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.