I need to pass a list of arrays to an external (?) function called gnuplot(), like in the example at the bottom (from
What if I have this:
@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
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);
What if I have this:
@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
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);