[Israel.pm] Radar graph

Assaf Gordon assafgordon at gmail.com
Tue Feb 19 10:26:26 PST 2013

Assaf Gordon wrote, On 02/19/2013 10:32 AM:
> Chanan Berler wrote, On 02/17/2013 12:27 PM:
>> I need to create a radar graph on my web site. I alreay tried using graphael - but found it with lots of bugs and very little of documentation. I have tried using jqplot but it has no radar kind of graph. Does anyone knows about web base graphic library (open source) that can create radar graphes?
>> P. S: radar graphes are also called splice graph or spider graphes
> The latest "hype" is client-side graphics, with frameworks such as d3js ( http://d3js.org/ ).

Or, if you're willing to bring in the "big guns", R can do radar plots, and you can call R from Perl.

The following example creates "chart.png" as a radar-plot.
It requires R, the "fmsb" R library and the Statistics::R perl module.

#!/usr/bin/env perl
use strict;
use warnings;
use Statistics::R;

my $output_file = "chart.png";

## Contrived example of passing Perl values to the R script
my @total_values  = ( 2.2, 3.3, 4.1 );
my @phys_values   = ( 1, 7, 14 ) ;
my @psycho_values = ( 2,2,2.8 );

my $R_script=<<"EOF";

# Radarchart example loosely based on
#   http://www.inside-r.org/packages/cran/fmsb/docs/radarchart

# Prepare Min/Max values
maxmin = data.frame(
	   psycho=c(3,0) )

# assume "total_values","phys_values","psycho_values"
# are existing R vector variables (will be created by Perl before running this script)
dat = data.frame(
	total = total_values,
	phys  = phys_values,
	psycho= psycho_values );

dat = rbind(maxmin,dat)


radarchart(dat,axistype=1,seg=3,plty=1,title="Perl/R RadarChart Example")

# Create the R object
my $R = Statistics::R->new( shared => 1 );

# Create R vector variables with the data values
$R->set("total_values", \@total_values);
$R->set("phys_values",  \@phys_values);
$R->set("psycho_values", \@psycho_values);

# Run the script


More information about the Perl mailing list