NAME
Lab::Moose::DataFile::Gnuplot - Text based data file ('Gnuplot style')
VERSION
version 3.630
SYNOPSIS
use Lab::Moose;
my $folder = datafolder();
# datafile with two simple 2D plots:
my $file = datafile(
type => 'Gnuplot',
folder => $folder,
filename => 'gnuplot-file.dat',
columns => [qw/time voltage temp/]
);
# add live plot
$file->add_plot(
x => 'time',
y => 'voltage',
curve_options => {with => 'points'},
);
$file->add_plot(
x => 'time',
y => 'temp',
hard_copy => 'gnuplot-file-time-temp.png'
);
$file->log(time => 1, voltage => 2, temp => 3);
# datafile with pm3d plot
my $datafile = datafile(
type => 'Gnuplot',
folder => datafolder(),
filename => 'data.dat',
columns => [qw/x y z/],
);
$datafile->add_plot(
type => 'pm3d',
x => 'x',
y => 'y',
z => 'z',
hard_copy => 'data.png',
);
for my $x (0..100) {
for my $y (0..100) {
$datafile->log(x => $x, y => $y, z => rand());
}
$datafile->new_block();
}
METHODS
new
Supports the following attributtes in addition to the Lab::Moose::DataFile requirements:
columns
(mandatory) arrayref of column names
precision
The numbers are formatted with a
%.${precision}g
format specifier. Default is 10.
log
$file->log(column1 => $value1, column2 => $value2, ...);
Log one line of data.
log_block
$file->log_block(
prefix => {column1 => $value1, ...},
block => $block,
add_newline => 1
);
Log a 1D or 2D PDL or array ref. The first dimension runs over the datafile rows. You can add prefix columns, which will be the same for each line in the block. E.g. when using a spectrum analyzer inside a voltage sweep, one would log the returned PDL prefixed with the sweep voltage.
new_block
$file->new_block()
print "\n" to the datafile.
log_comment
$file->log_comment(comment => $string);
log a comment string, which will be prefixed with '#'. If $string
contains newline characters, several lines of comments will be written.
add_plot
$file->add_plot(
type => 'pm3d',
x => 'x-column',
y => 'y-column',
z => 'z-column',
plot_options => {grid => 1},
hard_copy => 'myplot.png',
hard_copy_terminal => 'svg',
);
Add a new live plot to the datafile. Options:
type
Supported types:
points (default), pm3d
.x (mandatory)
Name of the column which is used for the x-axis.
y (mandatory)
Name of the column which is used for the y-axis.
z (mandatory for 3d plot)
Name of the column which is used tor the cb-axis in a pm3d plot.
terminal
gnuplot terminal. Default is qt.
terminal_options
HashRef of terminal options. For the qt and x11 terminals, this defaults to
{persist => 1, raise => 0}
.plot_options
HashRef of plotting options (See PDL::Graphics::Gnuplot for the complete list). Those are appended to the default plot options.
curve_options
HashRef of curve options (See PDL::Graphics::Gnuplot for the complete list).
refresh
Set this to a string, if you need to refresh the plot manually with the
refresh_plots
option. Multiple plots can share the same refresh handle string.Predefined refresh types:
'point'
Default for 2D plots. Replot for each new row.
'block'
Default for 3D plots. Replot when finishing a block.
hard_copy
Filename for the copy of the plot in the data folder. Default: Switch datafile filename suffix of datafile to the $terminal, e.g. data.dat => data.png. Mandatory if you add multiple plots to one datafile.
hard_copy_terminal
Terminal for hard_copy option. Use png terminal by default. The 'output' terminal option must be supported.
refresh_plots
$file->refresh_plots(refresh => $refresh_type);
# or
$file->refresh_plots();
Call refresh_plot
for each plot with hanle $handle
.
If the handle
argument is not given, refresh all plots.
COPYRIGHT AND LICENSE
This software is copyright (c) 2018 by the Lab::Measurement team; in detail:
Copyright 2016 Simon Reinhardt
2017 Andreas K. Huettel, Simon Reinhardt
2018 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.