NAME

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

VERSION

version 3.902

SYNOPSIS

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

 # use default terminal ('qt' on Linux)
 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 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.

COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by the Lab::Measurement team; in detail:

Copyright 2016       Simon Reinhardt
          2017       Andreas K. Huettel, Simon Reinhardt
          2018-2019  Simon Reinhardt

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.