J
joakim.grahl
I need to pass a list of arrays to a function gnuplot() in the CPAN
module Chart-Graph-3.2, like in the example at the bottom (from
http://search.cpan.org/~caidaperl/Chart-Graph-3.2/Graph/Gnuplot.pm).
Say I wish to plot the following functions (as in the example):
@plots = ($data, $fnc1, $fnc2);
Then I can't do:
gnuplot(\%options, @plots);
which drives me crazy
How can I pass the array of arrays, @plots, to gnuplot(), without
explicitly saying $plots[0], $plots[2], ... etc
- I've also tried doing stuff like this:
gnuplot(\%options, join(", ", @plots);
Any help greatly appreciated!
- Joakim
SNIP:
my %options = (
'title' => 'plot functions example',
'output file' => 'gnuplot5.png',
);
my $data = [{ 'title' => 'data 1',
'style' => 'lines',
'type' => 'matrix',
},
[
[0,10],
[3,30],
[6,0],
[9,-10],
[12,-0],
]
];
my $fnc1 = [{ 'title' => 'function 1',
'style' => 'lines',
'type' => 'function',
},
'10*sin(x)+2*cos(1.1 * x)+.5*tan(x)'
];
my $fnc2 = [{ 'title' => 'function 2',
'style' => 'lines',
'type' => 'function',
},
'20*sin(sqrt(2**x))/sqrt(2**x)'
];
gnuplot(\%options, $data, $fnc1, $fnc2);
/SNIP
module Chart-Graph-3.2, like in the example at the bottom (from
http://search.cpan.org/~caidaperl/Chart-Graph-3.2/Graph/Gnuplot.pm).
Say I wish to plot the following functions (as in the example):
@plots = ($data, $fnc1, $fnc2);
Then I can't do:
gnuplot(\%options, @plots);
which drives me crazy
How can I pass the array of arrays, @plots, to gnuplot(), without
explicitly saying $plots[0], $plots[2], ... etc
- I've also tried doing stuff like this:
gnuplot(\%options, join(", ", @plots);
Any help greatly appreciated!
- Joakim
SNIP:
my %options = (
'title' => 'plot functions example',
'output file' => 'gnuplot5.png',
);
my $data = [{ 'title' => 'data 1',
'style' => 'lines',
'type' => 'matrix',
},
[
[0,10],
[3,30],
[6,0],
[9,-10],
[12,-0],
]
];
my $fnc1 = [{ 'title' => 'function 1',
'style' => 'lines',
'type' => 'function',
},
'10*sin(x)+2*cos(1.1 * x)+.5*tan(x)'
];
my $fnc2 = [{ 'title' => 'function 2',
'style' => 'lines',
'type' => 'function',
},
'20*sin(sqrt(2**x))/sqrt(2**x)'
];
gnuplot(\%options, $data, $fnc1, $fnc2);
/SNIP