Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Creating Heat Map in perl

by Mr. Muskrat (Abbot)
on Sep 04, 2013 at 22:22 UTC ( #1052450=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Creating Heat Map in perl
in thread Creating Heat Map in perl

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.

#!/bin/env perl use strict; use warnings; use Imager::Heatmap; 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 $hmap->insert_datas(@point_datas); # 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.


Comment on Re^3: Creating Heat Map in perl
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1052450]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2015-07-02 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (30 votes), past polls