NAME
Gnuplot::Builder - object-oriented gnuplot script builder
SYNOPSIS
use Gnuplot::Builder;
my $script = gscript(grid => "y", mxtics => 5, mytics => 5);
$script->setq(
xlabel => 'x values',
ylabel => 'y values',
title => 'my plot'
);
$script->define('f(x)' => 'sin(x) / x');
$script->plot(
gfile('result.dat',
using => '1:2:3', title => "'Measured'", with => "yerrorbars"),
gfunc('f(x)', title => "'Theoretical'", with => "lines")
);
DESCRIPTION
This is a beta release. API may change in the future.
Gnuplot::Builder is a gnuplot script builder. Its advantages include:
Object-oriented. Script settings are encapsulated in a Gnuplot::Builder::Script object, and dataset parameters are in a Gnuplot::Builder::Dataset object. It eliminates global variables, which gnuplot uses extensively.
Thin. Gnuplot::Builder just builds a script text and streams it into a gnuplot process. Its behavior is extremely predictable and easy to debug.
Hierarchical. Gnuplot::Builder::Script and Gnuplot::Builder::Dataset objects support prototype-based inheritance, just like JavaScript objects. This is useful for hierarchical configuration.
Interactive. Gnuplot::Builder works well both in batch scripts and in interactive shells. Use Devel::REPL or Reply or whatever you like instead of the plain old gnuplot interative shell.
USAGE GUIDE
Gnuplot::Builder module is meant to be used in interactive shells. It exports some easy-to-type functions by default.
For batch scripts, I recommend using Gnuplot::Builder::Script and Gnuplot::Builder::Dataset directly. These modules are purely object-oriented, and won't mess up your namespace.
For Windows Users
Batch scripts using Gnuplot::Builder are fine in Windows.
In interactive shells, plot windows might not persist when you use regular Gnuplot::Builder. As a workaround, try Gnuplot::Builder::Wgnuplot.
EXPORTED FUNCTIONS
Gnuplot::Builder exports the following functions by default.
$script = gscript(@script_options)
Create a script object. It's just an alias for Gnuplot::Builder::Script->new(...)
. See Gnuplot::Builder::Script for detail.
$dataset = gfunc($funcion_spec, @dataset_options)
Create a dataset object representing a function, such as "sin(x)" and "f(x)". It's just an alias for Gnuplot::Builder::Dataset->new(...)
. See Gnuplot::Builder::Dataset for detail.
$dataset = gfile($filename, @dataset_options)
Create a dataset object representing a data file. It's just an alias for Gnuplot::Builder::Dataset->new_file(...)
. See Gnuplot::Builder::Dataset for detail.
$dataset = gdata($inline_data, @dataset_options)
Create a dataset object representing a data file. It's just an alias for Gnuplot::Builder::Dataset->new_data(...)
. See Gnuplot::Builder::Dataset for detail.
$help_message = ghelp(@help_args)
Run the gnuplot "help" command and return the help message. @help_args
is the arguments for the "help" command. They are joined with white spaces.
ghelp("style data");
## or you can say
ghelp("style", "data");
REPOSITORY
https://github.com/debug-ito/Gnuplot-Builder
BUGS AND FEATURE REQUESTS
Please report bugs and feature requests to my Github issues https://github.com/debug-ito/Gnuplot-Builder/issues.
Although I prefer Github, non-Github users can use CPAN RT https://rt.cpan.org/Public/Dist/Display.html?Name=Gnuplot-Builder. Please send email to bug-Gnuplot-Builder at rt.cpan.org
to report bugs if you do not have CPAN RT account.
AUTHOR
Toshio Ito, <toshioito at cpan.org>
LICENSE AND COPYRIGHT
Copyright 2014 Toshio Ito.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.