Gnuplot::Simple - A simple way to control Gnuplot
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.
Write the $dataset to the file $filename to create a gnuplot data file. Each element in $dataset should be of the form [[<c1>...<cn>],...]
The column values must not contain newlines (\n or \r) or quote marks. They can be non-ascii unicode.
Example usage:
use Gnuplot::Simple qw(exec_commands); my $d = [ [ 1,2 ],[ 2,3 ] ]; exec_commands( qq{ set terminal png set output "myfile.png" 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. The placeholder __DATA__ can be changed via the last parameter.
The function throws the gnuplot error message if execution fails.
This software is licensed under the same terms as Perl itself.
To install Gnuplot::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gnuplot::Simple
CPAN shell
perl -MCPAN -e shell install Gnuplot::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.