NAME

Gnuplot::Simple - A simple way to control Gnuplot

SYNOPSIS

Gnuplot can be controlled from Perl using a pipe. This modules faciliates the process to allow more convenient graph plotting from perl E.g.

use GnuPlot::Simple qw(write_data);

write_data("file.txt", [[ 1,2 ],[ 2,3 ]] );

For obvious reasons, gnuplot needs to be installed for this module to work. The presence of gnuplot is checked using the "which" shell command to verify that it is reachable via $PATH.

FUNCTION/ATTRIBUTES

write_data($filename, @datasets)

Write the $dataset to the file $filename to create a gnuplot data file. Each element in $datasets should be of the form [[<c1>...<cn>],...]

The column values must not contain newline or quote marks. They can be Unicode.

fun exec_commands ($c, $data)

Example usage:

my $d = [ [ 1,2 ],[ 2,3 ] ];
exec_commands(
    qq{
    set terminal png
    set output "$f"
    plot __DATA__ u 1:2 
    }, $d
);

The function takes a string of gnuplot commands $c that is piped to gnuplot. You can give a data set as well in the array ref $data. Then, any occurences of __DATA__ in $c are replaced by a temp file containing $data transformed to gnuplot format as done by write_data.

LICENSE

This software is licensed under the same terms as Perl itself.