The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Lab::Moose::Plot - Frontend to PDL::Graphics::Gnuplot.

SYNOPSIS

 use PDL;
 use Lab::Moose::Plot;

 # use default terminal 'qt'
 my $plot = Lab::Moose::Plot->new();

 # simple 2-D plot
 my $x = sequence(10);
 my $y = 2 * $x;

 $plot->plot(
     plot_options => {title => 'linear function'},
     curve_options => {legend => '2 * x'},
     data => [$x, $y]
 );

 # pm3d plot
 my $z = sin(rvals(300, 300) / 10);
 my $x = xvals($z);
 my $y = yvals($z);

 $plot->splot(
     plot_options => {
         title => 'a pm3d plot',
         pm3d => 1,
         view => 'map',
         surface => 0,
         palette => "model RGB defined ( 0 'red', 1 'yellow', 2 'white' )",
     },
     data => [$x, $y, $z],
 );

 
 # use a different terminal with default plot options

 my $plot = Lab::Moose::Plot(
     terminal => 'svg',
     terminal_options => {output => 'file.svg', enhanced => 0},
     plot_options => {pm3d => 1, view => 'map', surface => 0}
 );

DESCRIPTION

This is a small wrapper around PDL::Graphics::Gnuplot with the aim to make it accessible with our hash-based calling convention.

See the documentation of PDL::Graphics::Gnuplot for the allowed values of terminal-, plot- and curve-options.

METHODS

new

 my $plot = Lab::Moose::Plot->new(
     terminal => $terminal,
     terminal_options => \%terminal_options,
     plot_options => \%plot_options,
     curve_options => \%curve_options,
 );

Construct a new plotting backend. All arguments are optional. The default for terminal is 'qt'. For the 'qt' and 'x11' terminals, terminal_options defaults to {persist => 1, raise => 0 }. The default for plot_options and curve_options is the empty hash.

plot

 $plot->plot(
     plot_options => \%plot_options,
     curve_options => \%curve_options,
     data => [$x, $y, $z],
 );

Call PDL::Graphics::Gnuplot's plot function. The data array can contain either PDLs ore 1D arrad refs. The required number of elements in the array depends on the used plotting style.

splot

replot

splot and replot call PDL::Graphics::Gnuplot's splot and replot functions. Otherwise they behave like plot.