The synopsis for Imager::Heatmap can not be run as is. It doesn't create $base_img, it doesn't show how to properly use matrix, etc. So it is no surprise that what you ended up with didn't work.
Try this as a starting point. It uses your data and creates a png file in the current directory.
my $hmap = Imager::Heatmap->new(
xsize => 640, # Image width
ysize => 480, # Image height
xsigma => 10, # Sigma value of X-direction
ysigma => 10, # Sigma value of Y-direction
# @point_datas should be: ( [ x1, y1, weight1 ], [ x2, y2, weight2 ] .
my @point_datas = ( [ 10, 20, 50 ], [ 20, 40, 70 ] );
# Add point datas to construct density matrix
# After adding datas, get heatmap as Imager instance.
my $img = $hmap->draw;
# create png file in current directory
$img->write( file => './hm.png' );
Here's the generated heatmap image.
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||