mirror of
https://github.com/dkogan/feedgnuplot.git
synced 2025-09-19 03:38:08 +08:00
Compare commits
35 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
18994e68e1 | ||
![]() |
f8ed461571 | ||
![]() |
f01431dd1e | ||
![]() |
80b6030996 | ||
![]() |
232b68b819 | ||
![]() |
12eb829f16 | ||
![]() |
80b5d0ab61 | ||
![]() |
960c43e758 | ||
![]() |
2ecdfb9aef | ||
![]() |
fa7082b242 | ||
![]() |
c61e58da0a | ||
![]() |
c19dc4aa2a | ||
![]() |
238a0c1943 | ||
![]() |
42a8218fbe | ||
![]() |
4cfcf0fc35 | ||
![]() |
0e7f51f3f7 | ||
![]() |
01971c2434 | ||
![]() |
104accdd0d | ||
![]() |
605158b391 | ||
![]() |
0c32afacfd | ||
![]() |
1688496f34 | ||
![]() |
498047e785 | ||
![]() |
72adba82f7 | ||
![]() |
539b2035d8 | ||
![]() |
9b3cbc13be | ||
![]() |
a65abc6095 | ||
![]() |
5db86810b5 | ||
![]() |
d75b572875 | ||
![]() |
6cb1574e2b | ||
![]() |
4fd1c390ff | ||
![]() |
4163e24956 | ||
![]() |
13268a1fa8 | ||
![]() |
08fa97fdb5 | ||
![]() |
e19bdf51c4 | ||
![]() |
a9af1925e2 |
68
Changes
68
Changes
@@ -1,10 +1,74 @@
|
|||||||
feedgnuplot (1.30) unstable; urgency=low
|
feedgnuplot (1.38)
|
||||||
|
|
||||||
|
* hardcopy defaults:
|
||||||
|
- no enhanced text mode
|
||||||
|
- larger font size
|
||||||
|
|
||||||
|
-- Dima Kogan <dima@secretsauce.net> Wed, 27 Jul 2016 22:15:11 -0700
|
||||||
|
|
||||||
|
feedgnuplot (1.37)
|
||||||
|
|
||||||
|
* At the end of a streaming plot, include the last chunk of data
|
||||||
|
* Added --equation to the completions
|
||||||
|
|
||||||
|
-- Dima Kogan <dima@secretsauce.net> Fri, 01 Jan 2016 08:09:43 -0800
|
||||||
|
|
||||||
|
feedgnuplot (1.36)
|
||||||
|
|
||||||
|
* Added --equation to plot symbolic equations
|
||||||
|
|
||||||
|
-- Dima Kogan <dima@secretsauce.net> Fri, 13 Nov 2015 11:08:26 -0800
|
||||||
|
|
||||||
|
feedgnuplot (1.35)
|
||||||
|
|
||||||
|
* replaced a 'say' with 'print'. Should work better with ancient perls
|
||||||
|
* an "exit" command now has effect even with triggered-only replotting
|
||||||
|
|
||||||
|
* More sophisticated handling of termination conditions:
|
||||||
|
- Without --exit, we always end up with an interactive plot when the
|
||||||
|
input data is exhausted or when the user sends a ^C to the pipeline
|
||||||
|
- When streaming, the first ^C does not kill feedgnuplot
|
||||||
|
|
||||||
|
* Removed threading
|
||||||
|
|
||||||
|
-- Dima Kogan <dima@secretsauce.net> Sun, 01 Nov 2015 12:50:33 -0800
|
||||||
|
|
||||||
|
feedgnuplot (1.34)
|
||||||
|
|
||||||
|
* Fix for "Use of implicit split to @_ is deprecated". Thanks to Corey
|
||||||
|
Putkunz
|
||||||
|
|
||||||
|
* Declaring feedgnuplot as a package to let MetaCPAN index this
|
||||||
|
distribution
|
||||||
|
|
||||||
|
-- Dima Kogan <dima@secretsauce.net> Wed, 14 May 2014 00:45:24 -0700
|
||||||
|
|
||||||
|
feedgnuplot (1.33)
|
||||||
|
|
||||||
|
* fixed incorrect plotting of --timefmt --rangesize plots
|
||||||
|
|
||||||
|
-- Dima Kogan <dima@secretsauce.net> Thu, 06 Feb 2014 23:17:21 -0800
|
||||||
|
|
||||||
|
feedgnuplot (1.32)
|
||||||
|
|
||||||
|
* Added --rangesize and --rangesizeall. Different curves can now plot
|
||||||
|
different-size tuples
|
||||||
|
|
||||||
|
-- Dima Kogan <dima@secretsauce.net> Wed, 05 Feb 2014 13:57:58 -0800
|
||||||
|
|
||||||
|
feedgnuplot (1.31)
|
||||||
|
|
||||||
|
* Test suite requires gawk to get strftime()
|
||||||
|
|
||||||
|
-- Dima Kogan <dima@secretsauce.net> Sat, 25 Jan 2014 20:49:38 -0800
|
||||||
|
|
||||||
|
feedgnuplot (1.30)
|
||||||
|
|
||||||
* Added --with, --set, --unset, --style, --styleall
|
* Added --with, --set, --unset, --style, --styleall
|
||||||
|
|
||||||
-- Dima Kogan <dima@secretsauce.net> Fri, 24 Jan 2014 15:38:07 -0800
|
-- Dima Kogan <dima@secretsauce.net> Fri, 24 Jan 2014 15:38:07 -0800
|
||||||
|
|
||||||
feedgnuplot (1.29) unstable; urgency=low
|
feedgnuplot (1.29)
|
||||||
|
|
||||||
* added CPAN meta-data to require IPC::Run at build time
|
* added CPAN meta-data to require IPC::Run at build time
|
||||||
|
|
||||||
|
561
bin/feedgnuplot
561
bin/feedgnuplot
@@ -1,19 +1,20 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
package feedgnuplot; # for the metacpan indexer
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use Time::HiRes qw( usleep gettimeofday tv_interval );
|
use Time::HiRes qw( usleep gettimeofday tv_interval );
|
||||||
use IO::Handle;
|
use IO::Handle;
|
||||||
|
use IO::Select;
|
||||||
use List::Util qw( first );
|
use List::Util qw( first );
|
||||||
use Scalar::Util qw( looks_like_number );
|
use Scalar::Util qw( looks_like_number );
|
||||||
use Text::ParseWords;
|
use Text::ParseWords; # for shellwords
|
||||||
use threads;
|
|
||||||
use threads::shared;
|
|
||||||
use Thread::Queue;
|
|
||||||
use Pod::Usage;
|
use Pod::Usage;
|
||||||
use Time::Piece;
|
use Time::Piece;
|
||||||
|
|
||||||
my $VERSION = 1.30;
|
my $VERSION = 1.38;
|
||||||
|
|
||||||
my %options;
|
my %options;
|
||||||
interpretCommandline();
|
interpretCommandline();
|
||||||
@@ -26,16 +27,11 @@ interpretCommandline();
|
|||||||
# with --xlen, the offsets are preserved by using $curve->{datastring_offset} to
|
# with --xlen, the offsets are preserved by using $curve->{datastring_offset} to
|
||||||
# represent the offset IN THE ORIGINAL STRING of the current start of the
|
# represent the offset IN THE ORIGINAL STRING of the current start of the
|
||||||
# datastring
|
# datastring
|
||||||
|
|
||||||
|
|
||||||
my @curves = ();
|
my @curves = ();
|
||||||
|
|
||||||
# list mapping curve names to their indices in the @curves list
|
# list mapping curve names to their indices in the @curves list
|
||||||
my %curveIndices = ();
|
my %curveIndices = ();
|
||||||
|
|
||||||
# now start the data acquisition and plotting threads
|
|
||||||
my $dataQueue;
|
|
||||||
|
|
||||||
# Whether any new data has arrived since the last replot
|
# Whether any new data has arrived since the last replot
|
||||||
my $haveNewData;
|
my $haveNewData;
|
||||||
|
|
||||||
@@ -45,39 +41,16 @@ my $last_replot_time = [gettimeofday];
|
|||||||
# whether the previous replot was timer based
|
# whether the previous replot was timer based
|
||||||
my $last_replot_is_from_timer = 1;
|
my $last_replot_is_from_timer = 1;
|
||||||
|
|
||||||
my $streamingFinished : shared = undef;
|
|
||||||
|
|
||||||
if($options{stream})
|
my $prev_timed_replot_time = [gettimeofday];
|
||||||
{
|
my $this_replot_is_from_timer;
|
||||||
$dataQueue = Thread::Queue->new();
|
my $stdin = IO::Handle->new();
|
||||||
my $addThr = threads->create(\&mainThread);
|
die "Couldn't open STDIN" unless $stdin->fdopen(fileno(STDIN),"r");
|
||||||
|
my $selector = IO::Select->new( $stdin );
|
||||||
|
|
||||||
# spawn the plot updating thread. If I'm replotting from a data trigger, I don't need this
|
|
||||||
my $plotThr = threads->create(\&plotUpdateThread) if $options{stream} > 0;
|
|
||||||
|
|
||||||
while(<>)
|
|
||||||
{
|
|
||||||
chomp;
|
|
||||||
|
|
||||||
last if /^exit/;
|
mainThread();
|
||||||
|
|
||||||
# place every line of input to the queue, so that the plotting thread can process it. if we are
|
|
||||||
# using an implicit domain (x = line number), then we send it on the data queue also, since
|
|
||||||
# $. is not meaningful in the plotting thread
|
|
||||||
if(!$options{domain})
|
|
||||||
{
|
|
||||||
$_ .= " $.";
|
|
||||||
}
|
|
||||||
$dataQueue->enqueue($_);
|
|
||||||
}
|
|
||||||
|
|
||||||
$streamingFinished = 1;
|
|
||||||
|
|
||||||
$plotThr->join() if defined $plotThr;
|
|
||||||
$addThr->join();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ mainThread(); }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -116,20 +89,25 @@ sub interpretCommandline
|
|||||||
$options{extracmds} = [];
|
$options{extracmds} = [];
|
||||||
$options{set} = [];
|
$options{set} = [];
|
||||||
$options{unset} = [];
|
$options{unset} = [];
|
||||||
|
$options{equation} = [];
|
||||||
|
|
||||||
$options{curvestyleall} = '';
|
$options{curvestyleall} = '';
|
||||||
$options{styleall} = '';
|
$options{styleall} = '';
|
||||||
$options{with} = '';
|
$options{with} = '';
|
||||||
|
|
||||||
|
$options{rangesize} = [];
|
||||||
|
|
||||||
GetOptions(\%options, 'stream:s', 'domain!', 'dataid!', '3d!', 'colormap!', 'lines!', 'points!',
|
GetOptions(\%options, 'stream:s', 'domain!', 'dataid!', '3d!', 'colormap!', 'lines!', 'points!',
|
||||||
'circles', 'legend=s{2}', 'autolegend!', 'xlabel=s', 'ylabel=s', 'y2label=s', 'zlabel=s',
|
'circles', 'legend=s{2}', 'autolegend!', 'xlabel=s', 'ylabel=s', 'y2label=s', 'zlabel=s',
|
||||||
'title=s', 'xlen=f', 'ymin=f', 'ymax=f', 'xmin=s', 'xmax=s', 'y2min=f', 'y2max=f',
|
'title=s', 'xlen=f', 'ymin=f', 'ymax=f', 'xmin=s', 'xmax=s', 'y2min=f', 'y2max=f',
|
||||||
'zmin=f', 'zmax=f', 'y2=s@',
|
'zmin=f', 'zmax=f', 'y2=s@',
|
||||||
'style=s{2}', 'curvestyle=s{2}', 'curvestyleall=s', 'styleall=s', 'with=s', 'extracmds=s@', 'set=s@', 'unset=s@',
|
'style=s{2}', 'curvestyle=s{2}', 'curvestyleall=s', 'styleall=s', 'with=s', 'extracmds=s@', 'set=s@', 'unset=s@',
|
||||||
'square!', 'square_xy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!', 'timefmt=s',
|
'square!', 'square_xy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!', 'timefmt=s',
|
||||||
|
'equation=s@',
|
||||||
'histogram=s@', 'binwidth=f', 'histstyle=s',
|
'histogram=s@', 'binwidth=f', 'histstyle=s',
|
||||||
'terminal=s',
|
'terminal=s',
|
||||||
'extraValuesPerPoint=i', 'help', 'dump', 'exit', 'version',
|
'rangesize=s{2}', 'rangesizeall=i', 'extraValuesPerPoint=i',
|
||||||
|
'help', 'dump', 'exit', 'version',
|
||||||
'geometry=s') or pod2usage( -exitval => 1,
|
'geometry=s') or pod2usage( -exitval => 1,
|
||||||
-verbose => 1, # synopsis and args
|
-verbose => 1, # synopsis and args
|
||||||
-output => \*STDERR );
|
-output => \*STDERR );
|
||||||
@@ -176,7 +154,7 @@ sub interpretCommandline
|
|||||||
# arrays in order to preserve the ordering. I parse both of these into hashes
|
# arrays in order to preserve the ordering. I parse both of these into hashes
|
||||||
# because those are useful to have later. After this I can access individual
|
# because those are useful to have later. After this I can access individual
|
||||||
# legends with $options{legend_hash}{curveid}
|
# legends with $options{legend_hash}{curveid}
|
||||||
for my $listkey (qw(legend curvestyle))
|
for my $listkey (qw(legend curvestyle rangesize))
|
||||||
{
|
{
|
||||||
$options{"${listkey}_hash"} = {};
|
$options{"${listkey}_hash"} = {};
|
||||||
|
|
||||||
@@ -193,11 +171,37 @@ sub interpretCommandline
|
|||||||
exit -1;
|
exit -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( defined $options{rangesizeall} && defined $options{extraValuesPerPoint} )
|
||||||
|
{
|
||||||
|
print STDERR "Only one of --rangesizeall and --extraValuesPerPoint may be given\n";
|
||||||
|
exit -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# I now set up the rangesize to always be
|
||||||
|
# $options{rangesize_hash}{$id} // $options{rangesize_default}
|
||||||
|
if ( $options{rangesizeall} )
|
||||||
|
{
|
||||||
|
$options{rangesize_default} = $options{rangesizeall};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$options{rangesize_default} = 1;
|
||||||
|
|
||||||
|
$options{rangesize_default} += $options{extraValuesPerPoint} if ($options{extraValuesPerPoint});
|
||||||
|
$options{rangesize_default}++ if ($options{colormap});
|
||||||
|
$options{rangesize_default}++ if ($options{circles} );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# parse stream option. Allowed only numbers >= 0 or 'trigger'. After this code
|
# parse stream option. Allowed only numbers >= 0 or 'trigger'. After this code
|
||||||
# $options{stream} is
|
# $options{stream} is
|
||||||
# -1 for triggered replotting
|
# -1 for triggered replotting
|
||||||
# >0 for timed replotting
|
# >0 for timed replotting
|
||||||
# undef if not streaming
|
# undef if not streaming
|
||||||
|
#
|
||||||
|
# Note that '0' is not allowed, so !$options{stream} will do the expected
|
||||||
|
# thing
|
||||||
if(defined $options{stream})
|
if(defined $options{stream})
|
||||||
{
|
{
|
||||||
# if no streaming period is given, default to 1Hz.
|
# if no streaming period is given, default to 1Hz.
|
||||||
@@ -345,10 +349,8 @@ sub interpretCommandline
|
|||||||
$options{timefmt} =~ s/^\s*//;
|
$options{timefmt} =~ s/^\s*//;
|
||||||
$options{timefmt} =~ s/\s*$//;
|
$options{timefmt} =~ s/\s*$//;
|
||||||
|
|
||||||
my $Nfields = scalar split( ' ', $options{timefmt});
|
my $Nfields = () = split /\s+/, $options{timefmt}, -1;
|
||||||
$options{timefmt_Ncols} = $Nfields;
|
$options{timefmt_Ncols} = $Nfields;
|
||||||
my $regex_str = join( '\s+', ('\S+') x $Nfields );
|
|
||||||
$options{timefmt_regex} = qr/$regex_str/;
|
|
||||||
|
|
||||||
# make sure --xlen is an integer. With a timefmt xlen goes through strptime
|
# make sure --xlen is an integer. With a timefmt xlen goes through strptime
|
||||||
# and strftime, and those are integer-only
|
# and strftime, and those are integer-only
|
||||||
@@ -356,7 +358,7 @@ sub interpretCommandline
|
|||||||
{
|
{
|
||||||
if( $options{xlen} - int($options{xlen}) )
|
if( $options{xlen} - int($options{xlen}) )
|
||||||
{
|
{
|
||||||
say STDERR "When streaming --xlen MUST be an integer. Rounding up to the nearest second";
|
print STDERR "When streaming --xlen MUST be an integer. Rounding up to the nearest second\n";
|
||||||
$options{xlen} = 1 + int($options{xlen});
|
$options{xlen} = 1 + int($options{xlen});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -377,19 +379,6 @@ sub getGnuplotVersion
|
|||||||
return $gnuplotVersion;
|
return $gnuplotVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub plotUpdateThread
|
|
||||||
{
|
|
||||||
while(! $streamingFinished)
|
|
||||||
{
|
|
||||||
usleep( $options{stream} * 1e6 );
|
|
||||||
|
|
||||||
# indicate that the timer was the replot source
|
|
||||||
$dataQueue->enqueue('replot timertick');
|
|
||||||
}
|
|
||||||
|
|
||||||
$dataQueue->enqueue(undef);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub sendRangeCommand
|
sub sendRangeCommand
|
||||||
{
|
{
|
||||||
my ($name, $min, $max) = @_;
|
my ($name, $min, $max) = @_;
|
||||||
@@ -425,21 +414,64 @@ sub makeDomainNumeric
|
|||||||
return $domain0;
|
return $domain0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub getNextLine
|
||||||
|
{
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
$this_replot_is_from_timer = undef;
|
||||||
|
|
||||||
|
# if we're not streaming, or we're doing triggered-only replotting, simply
|
||||||
|
# do a blocking read
|
||||||
|
return $stdin->getline()
|
||||||
|
if (! $options{stream} || $options{stream} < 0);
|
||||||
|
|
||||||
|
|
||||||
|
my $now = [gettimeofday];
|
||||||
|
my $time_remaining = $options{stream} - tv_interval($prev_timed_replot_time, $now);
|
||||||
|
|
||||||
|
if ( $time_remaining < 0 )
|
||||||
|
{
|
||||||
|
$prev_timed_replot_time = $now;
|
||||||
|
$this_replot_is_from_timer = 1;
|
||||||
|
return 'replot';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($selector->can_read($time_remaining))
|
||||||
|
{
|
||||||
|
return $stdin->getline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub mainThread
|
sub mainThread
|
||||||
{
|
{
|
||||||
my $valuesPerPoint = 1;
|
|
||||||
if($options{extraValuesPerPoint}) { $valuesPerPoint += $options{extraValuesPerPoint}; }
|
|
||||||
if($options{colormap}) { $valuesPerPoint++; }
|
|
||||||
if($options{circles} ) { $valuesPerPoint++; }
|
|
||||||
|
|
||||||
local *PIPE;
|
local *PIPE;
|
||||||
my $dopersist = '';
|
my $dopersist = '';
|
||||||
|
|
||||||
if( !$options{stream} && getGnuplotVersion() >= 4.3)
|
if( getGnuplotVersion() >= 4.3 && # --persist not available before this
|
||||||
|
|
||||||
|
# --persist is needed for the "half-alive" state (see documentation for
|
||||||
|
# --exit). This state is only used with these options:
|
||||||
|
!$options{stream} && $options{exit})
|
||||||
{
|
{
|
||||||
$dopersist = '--persist';
|
$dopersist = '--persist';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# We trap SIGINT to kill the data input, but keep the plot up. see
|
||||||
|
# documentation for --exit
|
||||||
|
if ($options{stream} && !$options{exit})
|
||||||
|
{
|
||||||
|
$SIG{INT} = sub
|
||||||
|
{
|
||||||
|
print STDERR "$0 received SIGINT. Send again to quit\n";
|
||||||
|
$SIG{INT} = undef;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(exists $options{dump})
|
if(exists $options{dump})
|
||||||
{
|
{
|
||||||
*PIPE = *STDOUT;
|
*PIPE = *STDOUT;
|
||||||
@@ -465,11 +497,11 @@ sub mainThread
|
|||||||
}
|
}
|
||||||
|
|
||||||
my %terminalOpts =
|
my %terminalOpts =
|
||||||
( eps => 'postscript solid color enhanced eps',
|
( eps => 'postscript noenhanced solid color enhanced eps',
|
||||||
ps => 'postscript solid color landscape 10',
|
ps => 'postscript noenhanced solid color landscape 12',
|
||||||
pdf => 'pdfcairo solid color font ",10" size 11in,8.5in',
|
pdf => 'pdfcairo noenhanced solid color font ",12" size 11in,8.5in',
|
||||||
png => 'png size 1280,1024',
|
png => 'png noenhanced size 1280,1024',
|
||||||
svg => 'svg');
|
svg => 'svg noenhanced');
|
||||||
|
|
||||||
if( !defined $options{terminal} &&
|
if( !defined $options{terminal} &&
|
||||||
defined $outputfileType &&
|
defined $outputfileType &&
|
||||||
@@ -520,7 +552,7 @@ sub mainThread
|
|||||||
print(PIPE "set view equal xy\n");
|
print(PIPE "set view equal xy\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
# For the specified values, set the legend entries to 'title "blah blah"'
|
# For the specified values, set the legend entries to 'title "blah blah"'
|
||||||
if(@{$options{legend}})
|
if(@{$options{legend}})
|
||||||
{
|
{
|
||||||
# @{$options{legend}} is a list where consecutive pairs are (curveID,
|
# @{$options{legend}} is a list where consecutive pairs are (curveID,
|
||||||
@@ -535,7 +567,7 @@ sub mainThread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# add the extra curve options
|
# add the extra curve options
|
||||||
if(@{$options{curvestyle}})
|
if(@{$options{curvestyle}})
|
||||||
{
|
{
|
||||||
# @{$options{curvestyle}} is a list where consecutive pairs are (curveID,
|
# @{$options{curvestyle}} is a list where consecutive pairs are (curveID,
|
||||||
@@ -550,22 +582,22 @@ sub mainThread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# For the values requested to be printed on the y2 axis, set that
|
# For the values requested to be printed on the y2 axis, set that
|
||||||
addCurveOption($_, 'axes x1y2') foreach (@{$options{y2}});
|
addCurveOption($_, 'axes x1y2') foreach (@{$options{y2}});
|
||||||
|
|
||||||
# timefmt
|
# timefmt
|
||||||
if( $options{timefmt} )
|
if( $options{timefmt} )
|
||||||
{
|
{
|
||||||
print(PIPE "set timefmt '$options{timefmt}'\n");
|
print(PIPE "set timefmt '$options{timefmt}'\n");
|
||||||
print(PIPE "set xdata time\n");
|
print(PIPE "set xdata time\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
# add the extra global options
|
# add the extra global options
|
||||||
print(PIPE "$_\n") foreach (@{$options{extracmds}});
|
print(PIPE "$_\n") foreach (@{$options{extracmds}});
|
||||||
print(PIPE "set $_\n") foreach (@{$options{set}});
|
print(PIPE "set $_\n") foreach (@{$options{set}});
|
||||||
print(PIPE "unset $_\n") foreach (@{$options{unset}});
|
print(PIPE "unset $_\n") foreach (@{$options{unset}});
|
||||||
|
|
||||||
# set up histograms
|
# set up histograms
|
||||||
$options{binwidth} ||= 1; # if no binwidth given, set it to 1
|
$options{binwidth} ||= 1; # if no binwidth given, set it to 1
|
||||||
print PIPE
|
print PIPE
|
||||||
"set boxwidth $options{binwidth}\n" .
|
"set boxwidth $options{binwidth}\n" .
|
||||||
@@ -573,21 +605,6 @@ sub mainThread
|
|||||||
|
|
||||||
setCurveAsHistogram( $_ ) foreach (@{$options{histogram}});
|
setCurveAsHistogram( $_ ) foreach (@{$options{histogram}});
|
||||||
|
|
||||||
# regexp for a possibly floating point, possibly scientific notation number
|
|
||||||
my $numRE = '-?\d*\.?\d+(?:[Ee][-+]?\d+)?';
|
|
||||||
my $domainRE = $options{timefmt_regex} || $numRE;
|
|
||||||
|
|
||||||
|
|
||||||
# a point may be preceded by an id
|
|
||||||
my $pointRE = $options{dataid} ? '(\S+)\s+' : '()';
|
|
||||||
$pointRE .= '(' . join('\s+', ($numRE) x $valuesPerPoint) . ')';
|
|
||||||
$pointRE = qr/$pointRE/;
|
|
||||||
|
|
||||||
# set all the axis ranges
|
|
||||||
# If a bound isn't given I want to set it to the empty string, so I can communicate it simply to
|
|
||||||
# gnuplot
|
|
||||||
print PIPE "set xtics\n";
|
|
||||||
|
|
||||||
if(@{$options{y2}})
|
if(@{$options{y2}})
|
||||||
{
|
{
|
||||||
print PIPE "set ytics nomirror\n";
|
print PIPE "set ytics nomirror\n";
|
||||||
@@ -616,8 +633,7 @@ sub mainThread
|
|||||||
# number of seconds since the UNIX epoch.
|
# number of seconds since the UNIX epoch.
|
||||||
my $domain0_numeric;
|
my $domain0_numeric;
|
||||||
|
|
||||||
# I should be using the // operator, but I'd like to be compatible with perl 5.8
|
while( defined ($_ = getNextLine()) )
|
||||||
while( $_ = (defined $dataQueue ? $dataQueue->dequeue() : <>))
|
|
||||||
{
|
{
|
||||||
next if /^#/o;
|
next if /^#/o;
|
||||||
|
|
||||||
@@ -631,89 +647,104 @@ sub mainThread
|
|||||||
|
|
||||||
if(/^replot/o )
|
if(/^replot/o )
|
||||||
{
|
{
|
||||||
# /timertick/ determines if the timer was the source of the replot
|
replot( $domain0_numeric );
|
||||||
replot( $domain0_numeric, /timertick/ );
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
# /exit/ is handled in the data-reading thread
|
last if /^exit/o;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! /^replot/o)
|
# parse the incoming data lines. The format is
|
||||||
|
# x id0 dat0 id1 dat1 ....
|
||||||
|
# where idX is the ID of the curve that datX corresponds to
|
||||||
|
#
|
||||||
|
# $options{domain} indicates whether the initial 'x' is given or not (if not, the line
|
||||||
|
# number is used)
|
||||||
|
# $options{dataid} indicates whether idX is given or not (if not, the point order in the
|
||||||
|
# line is used)
|
||||||
|
# 3d plots require $options{domain}, and dictate "x y" for the domain instead of just "x"
|
||||||
|
|
||||||
|
my @fields = split;
|
||||||
|
|
||||||
|
if($options{domain})
|
||||||
{
|
{
|
||||||
# parse the incoming data lines. The format is
|
if( $options{timefmt} )
|
||||||
# x id0 dat0 id1 dat1 ....
|
|
||||||
# where idX is the ID of the curve that datX corresponds to
|
|
||||||
#
|
|
||||||
# $options{domain} indicates whether the initial 'x' is given or not (if not, the line
|
|
||||||
# number is used)
|
|
||||||
# $options{dataid} indicates whether idX is given or not (if not, the point order in the
|
|
||||||
# line is used)
|
|
||||||
# 3d plots require $options{domain}, and dictate "x y" for the domain instead of just "x"
|
|
||||||
|
|
||||||
if($options{domain})
|
|
||||||
{
|
{
|
||||||
/($domainRE)/go or next;
|
# no point if doing anything unless I have at least the domain and
|
||||||
$domain[0] = $1;
|
# 1 piece of data
|
||||||
$domain0_numeric = makeDomainNumeric( $domain[0] );
|
next if @fields < $options{timefmt_Ncols}+1;
|
||||||
|
|
||||||
if($options{'3d'})
|
$domain[0] = join (' ', splice( @fields, 0, $options{timefmt_Ncols}) );
|
||||||
{
|
$domain0_numeric = makeDomainNumeric( $domain[0] );
|
||||||
/($numRE)/go or next;
|
}
|
||||||
$domain[1] = $1;
|
elsif(!$options{'3d'})
|
||||||
}
|
{
|
||||||
elsif( $options{monotonic} )
|
# no point if doing anything unless I have at least the domain and
|
||||||
{
|
# 1 piece of data
|
||||||
if( defined $latestX && $domain0_numeric < $latestX )
|
next if @fields < 1+1;
|
||||||
{
|
|
||||||
# the x-coordinate of the new point is in the past, so I wipe out
|
|
||||||
# all the data and start anew. Before I wipe the old data, I
|
|
||||||
# replot the old data
|
|
||||||
replot( $domain0_numeric );
|
|
||||||
clearCurves();
|
|
||||||
$latestX = undef;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ $latestX = $domain0_numeric; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$domain[0] = $domain0_numeric = shift @fields;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
# since $. is not meaningful in the plotting thread if we're using the data queue, we pass
|
# no point if doing anything unless I have at least the domain and
|
||||||
# $. on the data queue in that case
|
# 1 piece of data
|
||||||
if(defined $dataQueue)
|
next if @fields < 2+1;
|
||||||
|
|
||||||
|
@domain = splice(@fields, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $options{monotonic} )
|
||||||
|
{
|
||||||
|
if( defined $latestX && $domain0_numeric < $latestX )
|
||||||
{
|
{
|
||||||
s/ ([\d]+)$//o;
|
# the x-coordinate of the new point is in the past, so I wipe out
|
||||||
$domain[0] = $1;
|
# all the data and start anew. Before I wipe the old data, I
|
||||||
|
# replot the old data
|
||||||
|
replot( $domain0_numeric );
|
||||||
|
clearCurves();
|
||||||
|
$latestX = undef;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ $latestX = $domain0_numeric; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$domain[0] = $.;
|
||||||
|
$domain0_numeric = makeDomainNumeric( $domain[0] );
|
||||||
|
}
|
||||||
|
|
||||||
|
my $id = -1;
|
||||||
|
|
||||||
|
while(@fields)
|
||||||
|
{
|
||||||
|
if($options{dataid})
|
||||||
|
{
|
||||||
|
$id = shift @fields;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$domain[0] = $.;
|
$id++;
|
||||||
}
|
}
|
||||||
$domain0_numeric = makeDomainNumeric( $domain[0] );
|
|
||||||
}
|
|
||||||
|
|
||||||
my $id = -1;
|
# I'd like to use //, but I guess some people are still on perl 5.8
|
||||||
while (/$pointRE/go)
|
my $rangesize = exists $options{rangesize_hash}{$id} ?
|
||||||
{
|
$options{rangesize_hash}{$id} :
|
||||||
if($1 ne '') {$id = $1;}
|
$options{rangesize_default};
|
||||||
else {$id++; }
|
|
||||||
|
last if @fields < $rangesize;
|
||||||
|
|
||||||
pushPoint(getCurve($id),
|
pushPoint(getCurve($id),
|
||||||
"@domain $2\n", $domain0_numeric);
|
join(' ',
|
||||||
}
|
@domain,
|
||||||
|
splice( @fields, 0, $rangesize ) ) . "\n",
|
||||||
|
$domain0_numeric);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# if we were streaming, we're now done!
|
|
||||||
if( $options{stream} )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
# finished reading in all. Plot what we have
|
# finished reading in all. Plot what we have
|
||||||
plotStoredData();
|
plotStoredData() unless $options{stream} && $options{exit};
|
||||||
|
|
||||||
if ( defined $options{hardcopy})
|
if ( defined $options{hardcopy})
|
||||||
{
|
{
|
||||||
@@ -722,7 +753,7 @@ sub mainThread
|
|||||||
# sleep until the plot file exists, and it is closed. Sometimes the output
|
# sleep until the plot file exists, and it is closed. Sometimes the output
|
||||||
# is still being written at this point. If the output filename starts with
|
# is still being written at this point. If the output filename starts with
|
||||||
# '|', gnuplot pipes the output to that process, instead of writing to a
|
# '|', gnuplot pipes the output to that process, instead of writing to a
|
||||||
# file. In that case I don't make sure the file exists, since there IS not
|
# file. In that case I don't make sure the file exists, since there IS no
|
||||||
# file
|
# file
|
||||||
if( $options{hardcopy} !~ /^\|/ )
|
if( $options{hardcopy} !~ /^\|/ )
|
||||||
{
|
{
|
||||||
@@ -734,6 +765,13 @@ sub mainThread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# data exhausted. If we're killed now, then we should peacefully die.
|
||||||
|
if($options{stream} && !$options{exit})
|
||||||
|
{
|
||||||
|
print STDERR "Input data exhausted\n";
|
||||||
|
$SIG{INT} = undef;
|
||||||
|
}
|
||||||
|
|
||||||
# we persist gnuplot, so we shouldn't need this sleep. However, once
|
# we persist gnuplot, so we shouldn't need this sleep. However, once
|
||||||
# gnuplot exits, but the persistent window sticks around, you can no
|
# gnuplot exits, but the persistent window sticks around, you can no
|
||||||
# longer interactively zoom the plot. So we still sleep
|
# longer interactively zoom the plot. So we still sleep
|
||||||
@@ -777,7 +815,9 @@ sub plotStoredData
|
|||||||
my @nonemptyCurves = grep { $_->{datastring} } @curves;
|
my @nonemptyCurves = grep { $_->{datastring} } @curves;
|
||||||
my @extraopts = map {$_->{options}} @nonemptyCurves;
|
my @extraopts = map {$_->{options}} @nonemptyCurves;
|
||||||
|
|
||||||
my $body = join(', ' , map({ "'-' $_" } @extraopts) );
|
my $body = join('', map { "$_," } @{$options{equation}});
|
||||||
|
$body .= join(', ' , map({ "'-' $_" } @extraopts) );
|
||||||
|
|
||||||
if($options{'3d'}) { print PIPE "splot $body\n"; }
|
if($options{'3d'}) { print PIPE "splot $body\n"; }
|
||||||
else { print PIPE "plot $body\n"; }
|
else { print PIPE "plot $body\n"; }
|
||||||
|
|
||||||
@@ -824,7 +864,19 @@ sub updateCurveOptions
|
|||||||
my $usingoptions = '';
|
my $usingoptions = '';
|
||||||
if( $options{timefmt} )
|
if( $options{timefmt} )
|
||||||
{
|
{
|
||||||
$usingoptions = "using 1:" . ($options{timefmt_Ncols}+1);
|
# with --timefmt I need an explicit 'using' specification. I specify the
|
||||||
|
# columns as 1:2:3..... I need the right number of columns (this is given
|
||||||
|
# as 1 + rangesize). I also need to start the range at the first column
|
||||||
|
# past the timefmt
|
||||||
|
|
||||||
|
# I'd like to use //, but I guess some people are still on perl 5.8
|
||||||
|
my $rangesize = exists $options{rangesize_hash}{$id} ?
|
||||||
|
$options{rangesize_hash}{$id} :
|
||||||
|
$options{rangesize_default};
|
||||||
|
|
||||||
|
my @rest = map {$_ + $options{timefmt_Ncols}} (1..$rangesize);
|
||||||
|
|
||||||
|
$usingoptions = "using 1:" . join(':', @rest);
|
||||||
}
|
}
|
||||||
|
|
||||||
$curve->{options} = "$histoptions $usingoptions $titleoption $curve->{extraoptions} $curvestyleall";
|
$curve->{options} = "$histoptions $usingoptions $titleoption $curve->{extraoptions} $curvestyleall";
|
||||||
@@ -919,7 +971,7 @@ sub replot
|
|||||||
# }
|
# }
|
||||||
|
|
||||||
|
|
||||||
my ($domain0_numeric, $replot_is_from_timer) = @_;
|
my ($domain0_numeric) = @_;
|
||||||
|
|
||||||
my $now = [gettimeofday];
|
my $now = [gettimeofday];
|
||||||
|
|
||||||
@@ -929,7 +981,7 @@ sub replot
|
|||||||
# if the last replot was timer-based, but this one isn't, force a replot.
|
# if the last replot was timer-based, but this one isn't, force a replot.
|
||||||
# This makes sure that a replot happens for a domain rollover shortly
|
# This makes sure that a replot happens for a domain rollover shortly
|
||||||
# after a timer replot
|
# after a timer replot
|
||||||
!$replot_is_from_timer && $last_replot_is_from_timer ||
|
!$this_replot_is_from_timer && $last_replot_is_from_timer ||
|
||||||
|
|
||||||
# if enough time has elapsed since the last replot, it's ok to replot
|
# if enough time has elapsed since the last replot, it's ok to replot
|
||||||
tv_interval ( $last_replot_time, $now ) > 0.8*$options{stream} )
|
tv_interval ( $last_replot_time, $now ) > 0.8*$options{stream} )
|
||||||
@@ -955,7 +1007,7 @@ sub replot
|
|||||||
|
|
||||||
# update replot state
|
# update replot state
|
||||||
$last_replot_time = $now;
|
$last_replot_time = $now;
|
||||||
$last_replot_is_from_timer = $replot_is_from_timer;
|
$last_replot_is_from_timer = $this_replot_is_from_timer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1112,17 +1164,24 @@ conjunction with C<--dataid>.
|
|||||||
=head3 Multi-value style support
|
=head3 Multi-value style support
|
||||||
|
|
||||||
Depending on how gnuplot is plotting the data, more than one value may be needed
|
Depending on how gnuplot is plotting the data, more than one value may be needed
|
||||||
to represent a single point. For example, the script has support to plot all the
|
to represent the range of a single point. Basic 2D plots have 2 numbers
|
||||||
data with C<--circles>. This requires a radius to be specified for each point in
|
representing each point: 1 domain and 1 range. But if plotting with
|
||||||
addition to the position of the point. Thus, when plotting with C<--circles>, 2
|
C<--circles>, for instance, then there's an extra range value: the radius. A
|
||||||
numbers are read for each data point instead of 1. A similar situation exists
|
similar situation exists with C<--colormap> where each point contains the
|
||||||
with C<--colormap> where each point contains the position I<and> the color.
|
position I<and> the color. There are other gnuplot styles that require more data
|
||||||
There are other gnuplot styles that require more data (such as error bars), but
|
(such as error bars), but none of these are directly supported by the script.
|
||||||
none of these are directly supported by the script. They can still be used,
|
They can still be used, however, by specifying the specific style with
|
||||||
though, by specifying the specific style with C<--style>, and specifying how
|
C<--style>, and specifying how many values are needed for each point with
|
||||||
many extra values are needed for each point with C<--extraValuesPerPoint extra>.
|
C<--rangesizeall> or C<--rangesize> or C<--extraValuesPerPoint>. Those options
|
||||||
C<--extraValuesPerPoint> is ONLY needed for the styles not explicitly supported;
|
that specify the range size are required I<only> for styles not explicitly
|
||||||
supported styles set that variable automatically.
|
supported by feedgnuplot; supported styles do the right thing automatically.
|
||||||
|
|
||||||
|
More examples: if making a 2d plot of y error bars where gnuplot expects a
|
||||||
|
(x,y,ydelta) tuple for each point, you want C<--rangesizeall 2> because you have
|
||||||
|
one domain value (x) and 2 range values (y,ydelta). Gnuplot can also plot
|
||||||
|
lopsided y errorbars by giving a tuple (x,y,ylow,yhigh). This is similar as
|
||||||
|
before, but you want C<--rangesizeall 3> instead.
|
||||||
|
|
||||||
|
|
||||||
=head3 3D data
|
=head3 3D data
|
||||||
|
|
||||||
@@ -1157,7 +1216,7 @@ C<--xmin> and C<--xmax> I<must> use the format passed in to C<--timefmt>
|
|||||||
|
|
||||||
Using this option changes both the way the input is parsed I<and> the way the
|
Using this option changes both the way the input is parsed I<and> the way the
|
||||||
x-axis tics are labelled. Gnuplot tries to be intelligent in this labelling, but
|
x-axis tics are labelled. Gnuplot tries to be intelligent in this labelling, but
|
||||||
it doesn't always to what the user wants. The labelling can be controlled with
|
it doesn't always do what the user wants. The labelling can be controlled with
|
||||||
the gnuplot C<set format> command, which takes the same type of format string as
|
the gnuplot C<set format> command, which takes the same type of format string as
|
||||||
C<--timefmt>. Example:
|
C<--timefmt>. Example:
|
||||||
|
|
||||||
@@ -1365,8 +1424,7 @@ Interpret the X data as a time/date, parsed with the given format
|
|||||||
C<--colormap>
|
C<--colormap>
|
||||||
|
|
||||||
Show a colormapped xy plot. Requires extra data for the color. zmin/zmax can be
|
Show a colormapped xy plot. Requires extra data for the color. zmin/zmax can be
|
||||||
used to set the extents of the colors. Automatically increments
|
used to set the extents of the colors. Automatically sets the C<--rangesize>.
|
||||||
C<--extraValuesPerPoint>
|
|
||||||
|
|
||||||
=item
|
=item
|
||||||
|
|
||||||
@@ -1394,8 +1452,7 @@ Do [not] draw points
|
|||||||
C<--circles>
|
C<--circles>
|
||||||
|
|
||||||
Plot with circles. This requires a radius be specified for each point.
|
Plot with circles. This requires a radius be specified for each point.
|
||||||
Automatically increments C<--extraValuesPerPoint>). C<Not> supported for 3d
|
Automatically sets the C<--rangesize>. C<Not> supported for 3d plots.
|
||||||
plots.
|
|
||||||
|
|
||||||
=item
|
=item
|
||||||
|
|
||||||
@@ -1479,12 +1536,17 @@ in the plot. Defaults to 1.0 if not given.
|
|||||||
|
|
||||||
C<--histstyle style>
|
C<--histstyle style>
|
||||||
|
|
||||||
Normally, histograms are generated with the 'smooth freq' gnuplot style.
|
Normally, histograms are generated with the 'smooth frequency' gnuplot style.
|
||||||
C<--histstyle> can be used to select different 'smooth' settings. Allowed are
|
C<--histstyle> can be used to select different C<smooth> settings (see the
|
||||||
'unique', 'cumulative' and 'cnormal'. 'unique' indicates whether a bin has at
|
gnuplot C<help smooth> page for more info). Allowed values are 'frequency' (the
|
||||||
least one item in it: instead of counting the items, it'll always report 0 or 1.
|
default), 'unique', 'cumulative' and 'cnormal'. 'unique' indicates whether a bin
|
||||||
'cumulative' is the integral of the "normal" histogram. 'cnormal' is like
|
has at least one item in it: instead of counting the items, it'll always report
|
||||||
'cumulative', but rescaled to end up at 1.0.
|
0 or 1. 'cumulative' is the integral of the 'frequency' histogram. 'cnormal' is
|
||||||
|
like 'cumulative', but rescaled to end up at 1.0. Note that there's no
|
||||||
|
normalized 'frequency' option because gnuplot does not provide one.
|
||||||
|
|
||||||
|
|
||||||
|
C<help smooth>
|
||||||
|
|
||||||
=item
|
=item
|
||||||
|
|
||||||
@@ -1552,6 +1614,34 @@ times.
|
|||||||
|
|
||||||
=item
|
=item
|
||||||
|
|
||||||
|
C<--equation xxx>
|
||||||
|
|
||||||
|
Gnuplot can plot both data and symbolic equations. C<feedgnuplot> generally
|
||||||
|
plots data, but with this option can plot symbolic equations I<also>. This is
|
||||||
|
generally intended to augment data plots, since for equation-only plots you
|
||||||
|
don't need C<feedgnuplot>. C<--equation> can be passed multiple times for
|
||||||
|
multiple equations. The given strings are passed to gnuplot directly without any
|
||||||
|
thing added or removed, so styling and such should be applied in the string. A
|
||||||
|
basic example:
|
||||||
|
|
||||||
|
seq 100 | awk '{print $1/10, $1/100}' |
|
||||||
|
feedgnuplot --with 'lines lw 3' --domain --ymax 1
|
||||||
|
--equation 'sin(x)/x' --equation 'cos(x)/x with lines lw 4'
|
||||||
|
|
||||||
|
Here I plot the incoming data (points along a line) with the given style (a line
|
||||||
|
with thickness 3), I<and> I plot two damped sinusoids on the same plot. The
|
||||||
|
sinusoids are not affected by C<feedgnuplot> styling, so their styles are set
|
||||||
|
separately, as in this example. More complicated example:
|
||||||
|
|
||||||
|
seq 360 | perl -nE '$th=$_/360 * 3.14*2; $c=cos($th); $s=sin($th); say "$c $s"' |
|
||||||
|
feedgnuplot --domain --square
|
||||||
|
--set parametric --set "trange [0:2*3.14]" --equation "sin(t),cos(t)"
|
||||||
|
|
||||||
|
Here the data I generate is points along the unit circle. I plot these as
|
||||||
|
points, and I I<also> plot a true circle as a parametric equation.
|
||||||
|
|
||||||
|
=item
|
||||||
|
|
||||||
C<--square>
|
C<--square>
|
||||||
|
|
||||||
Plot data with aspect ratio 1. For 3D plots, this controls the aspect ratio for
|
Plot data with aspect ratio 1. For 3D plots, this controls the aspect ratio for
|
||||||
@@ -1599,13 +1689,32 @@ replotted before being purged
|
|||||||
|
|
||||||
=item
|
=item
|
||||||
|
|
||||||
|
C<--rangesize curveID xxx>
|
||||||
|
|
||||||
|
The options C<--rangesizeall>, C<--rangesize> and C<--extraValuesPerPoint> set
|
||||||
|
the number of values are needed to represent each point being plotted (see
|
||||||
|
L</"Multi-value style support"> above). These options are I<only> needed if
|
||||||
|
unknown styles are used, with C<--styleall> or C<--with> for instance.
|
||||||
|
|
||||||
|
C<--rangesize> is used to set how many values are needed to represent the range
|
||||||
|
of a point for a particular curve. This overrides any defaults that may exist
|
||||||
|
for this curve only.
|
||||||
|
|
||||||
|
=item
|
||||||
|
|
||||||
|
C<--rangesizeall xxx>
|
||||||
|
|
||||||
|
Like C<--rangesize>, but applies to I<all> the curves.
|
||||||
|
|
||||||
C<--extraValuesPerPoint xxx>
|
C<--extraValuesPerPoint xxx>
|
||||||
|
|
||||||
How many extra values are given for each data point. Normally this is 0, and
|
Like C<--rangesizeall>, but instead of overriding the default, adds to it. For
|
||||||
does not need to be specified, but sometimes we want extra data, like for colors
|
example, if plotting non-lopsided y errorbars gnuplot wants (x,y,ydelta) tuples.
|
||||||
or point sizes or error bars, etc. feedgnuplot options that require this
|
These can be specified both with C<--rangesizeall 2> (because there are 2 range
|
||||||
(colormap, circles) automatically set it. This option is ONLY needed if unknown
|
values) or C<--extraValuesPerPoint 1> (because there's 1 more value than usual).
|
||||||
styles are used, with C<--styleall> or C<--with> for instance
|
|
||||||
|
This option is I<only> needed if unknown styles are used, with C<--styleall> or
|
||||||
|
C<--with> for instance.
|
||||||
|
|
||||||
=item
|
=item
|
||||||
|
|
||||||
@@ -1618,10 +1727,80 @@ is possible to send the output produced this way to gnuplot directly.
|
|||||||
|
|
||||||
C<--exit>
|
C<--exit>
|
||||||
|
|
||||||
Terminate the feedgnuplot process after passing data to gnuplot. The window will
|
This controls the details of what happens when the input data is exhausted, or
|
||||||
persist but will not be interactive. Without this option feedgnuplot keeps
|
when some part of the C<feedgnuplot> pipeline is killed. This option does
|
||||||
running and must be killed by the user. Note that this option works only with
|
different things depending on whether C<--stream> is active, so read this
|
||||||
later versions of gnuplot and only with some gnuplot terminals.
|
closely.
|
||||||
|
|
||||||
|
With interactive gnuplot terminals (qt, x11, wxt), the plot windows live in a
|
||||||
|
separate process from the main C<gnuplot> process. It is thus possible for the
|
||||||
|
main C<gnuplot> process to exit, while leaving the plot windows up (a caveat is
|
||||||
|
that such decapitated windows aren't interactive). To be clear, there are 3
|
||||||
|
possible states:
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item Alive: C<feedgnuplot>, C<gnuplot> alive, plot window process alive, no
|
||||||
|
shell prompt (shell busy with C<feedgnuplot>)
|
||||||
|
|
||||||
|
=item Half-alive: C<feedgnuplot>, C<gnuplot> dead, plot window process alive
|
||||||
|
(but non-interactive), shell prompt available
|
||||||
|
|
||||||
|
=item Dead: C<feedgnuplot>, C<gnuplot> dead, plot window process dead, shell
|
||||||
|
prompt available
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
The C<--exit> option controls the details of this behavior. The possibilities
|
||||||
|
are:
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item No C<--stream>, input pipe is exhausted (all data read in)
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item default; no C<--exit>
|
||||||
|
|
||||||
|
Alive. Need to Ctrl-C to get back into the shell
|
||||||
|
|
||||||
|
=item C<--exit>
|
||||||
|
|
||||||
|
Half-alive. Non-interactive prompt up, and the shell accepts new commands.
|
||||||
|
Without C<--stream> the goal is to show a plot, so a Dead state is not useful
|
||||||
|
here.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=item C<--stream>, input pipe is exhausted (all data read in) or the
|
||||||
|
C<feedgnuplot> process terminated
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item default; no C<--exit>
|
||||||
|
|
||||||
|
Alive. Need to Ctrl-C to get back into the shell
|
||||||
|
|
||||||
|
=item C<--exit>
|
||||||
|
|
||||||
|
Dead. No plot is shown, and the shell accepts new commands. With C<--stream> the
|
||||||
|
goal is to show a plot as the data comes in, which we have been doing. Now that
|
||||||
|
we're done, we can clean up everything.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
Note that one usually invokes C<feedgnuplot> as a part of a shell pipeline:
|
||||||
|
|
||||||
|
$ write_data | feedgnuplot
|
||||||
|
|
||||||
|
If the user terminates this pipeline with ^C, then I<all> the processes in the
|
||||||
|
pipeline receive SIGINT. This normally kills C<feedgnuplot> and all its
|
||||||
|
C<gnuplot> children, and we let this happen unless C<--stream> and no C<--exit>.
|
||||||
|
If C<--stream> and no C<--exit>, then we ignore the first ^C. The data feeder
|
||||||
|
dies, and we behave as if the input data was exhausted. A second ^C kills us
|
||||||
|
also.
|
||||||
|
|
||||||
=item
|
=item
|
||||||
|
|
||||||
@@ -1675,10 +1854,12 @@ in a Thinkpad.
|
|||||||
$ while true; do cat /proc/acpi/ibm/thermal | awk '{$1=""; print}' ; sleep 1; done |
|
$ while true; do cat /proc/acpi/ibm/thermal | awk '{$1=""; print}' ; sleep 1; done |
|
||||||
feedgnuplot --stream --xlen 100 --lines --autolegend --ymax 100 --ymin 20 --ylabel 'Temperature (deg C)'
|
feedgnuplot --stream --xlen 100 --lines --autolegend --ymax 100 --ymin 20 --ylabel 'Temperature (deg C)'
|
||||||
|
|
||||||
=head2 Plotting a histogram of file sizes in a directory
|
=head2 Plotting a histogram of file sizes in a directory, granular to 10MB
|
||||||
|
|
||||||
$ ls -l | awk '{print $5/1e6}' |
|
$ ls -l | awk '{print $5/1e6}' |
|
||||||
feedgnuplot --histogram 0 --with boxes --ymin 0 --xlabel 'File size (MB)' --ylabel Frequency
|
feedgnuplot --histogram 0 --with boxes
|
||||||
|
--binwidth 10 --set 'style fill solid'
|
||||||
|
--ymin 0 --xlabel 'File size (MB)' --ylabel Frequency
|
||||||
|
|
||||||
=head1 ACKNOWLEDGEMENT
|
=head1 ACKNOWLEDGEMENT
|
||||||
|
|
||||||
|
@@ -15,9 +15,12 @@ complete -W \
|
|||||||
--dump \
|
--dump \
|
||||||
--exit \
|
--exit \
|
||||||
--extraValuesPerPoint \
|
--extraValuesPerPoint \
|
||||||
|
--rangesizeall \
|
||||||
|
--rangesize \
|
||||||
--extracmds \
|
--extracmds \
|
||||||
--set \
|
--set \
|
||||||
--unset \
|
--unset \
|
||||||
|
--equation \
|
||||||
--geometry \
|
--geometry \
|
||||||
--hardcopy \
|
--hardcopy \
|
||||||
--help \
|
--help \
|
||||||
|
@@ -32,12 +32,15 @@ _arguments -S
|
|||||||
'*--extracmds[Additional gnuplot commands]:command' \
|
'*--extracmds[Additional gnuplot commands]:command' \
|
||||||
'*--set[Additional 'set' gnuplot commands]:set-option' \
|
'*--set[Additional 'set' gnuplot commands]:set-option' \
|
||||||
'*--unset[Additional 'unset' gnuplot commands]:unset-option' \
|
'*--unset[Additional 'unset' gnuplot commands]:unset-option' \
|
||||||
|
'*--equation[Raw symbolic equation]:equation' \
|
||||||
'--square[Plot data with square aspect ratio]' \
|
'--square[Plot data with square aspect ratio]' \
|
||||||
'--square_xy[For 3D plots, set square aspect ratio for ONLY the x,y axes]' \
|
'--square_xy[For 3D plots, set square aspect ratio for ONLY the x,y axes]' \
|
||||||
'--hardcopy[Plot to a file]:filename' \
|
'--hardcopy[Plot to a file]:filename' \
|
||||||
'--maxcurves[The maximum allowed number of curves]:number of curves' \
|
'--maxcurves[The maximum allowed number of curves]:number of curves' \
|
||||||
'(--3d)--monotonic[Resets plot if an X in the past is seen]' \
|
'(--3d)--monotonic[Resets plot if an X in the past is seen]' \
|
||||||
'--extraValuesPerPoint[How many extra values are given for each data point]:N'\
|
'(--rangesizeall)--extraValuesPerPoint[How many extra values are given for each data range]:N'\
|
||||||
|
'(--extraValuesPerPoint)--rangesizeall[How many values are given for each data range]:N'\
|
||||||
|
'*--rangesize[How many values comprise a data range in this curve]:curve id: :N:' \
|
||||||
'--dump[Instead of printing to gnuplot, print to STDOUT]' \
|
'--dump[Instead of printing to gnuplot, print to STDOUT]' \
|
||||||
'--geometry[The X11 geometry string]:geometry string:' \
|
'--geometry[The X11 geometry string]:geometry string:' \
|
||||||
'*--curvestyle[Additional styles for a curve]:curve id: :style:' \
|
'*--curvestyle[Additional styles for a curve]:curve id: :style:' \
|
||||||
|
202
t/plots.t
202
t/plots.t
@@ -17,14 +17,20 @@ BEGIN {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
open(my $pipe, 'gnuplot --version |');
|
my $gawkversion = `gawk -V`;
|
||||||
if( !$pipe )
|
if( !$gawkversion || $@ )
|
||||||
|
{
|
||||||
|
print("1..0 # Skip: gawk is required for strftime() in the test suite. Skipping tests.\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $gnuplotVersion = `gnuplot --version`;
|
||||||
|
if( !$gnuplotVersion || $@)
|
||||||
{
|
{
|
||||||
print("1..0 # Skip: gnuplot not installed. Tests require ver. 4.6.4; feedgnuplot works with any.\n");
|
print("1..0 # Skip: gnuplot not installed. Tests require ver. 4.6.4; feedgnuplot works with any.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $gnuplotVersion = <$pipe>;
|
|
||||||
chomp $gnuplotVersion;
|
chomp $gnuplotVersion;
|
||||||
if ($gnuplotVersion ne "gnuplot 4.6 patchlevel 4")
|
if ($gnuplotVersion ne "gnuplot 4.6 patchlevel 4")
|
||||||
{
|
{
|
||||||
@@ -33,7 +39,7 @@ BEGIN {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use Test::More tests => 52;
|
use Test::More tests => 58;
|
||||||
use File::Temp 'tempfile';
|
use File::Temp 'tempfile';
|
||||||
use IPC::Run 'run';
|
use IPC::Run 'run';
|
||||||
use String::ShellQuote;
|
use String::ShellQuote;
|
||||||
@@ -320,7 +326,7 @@ tryplot( testname => 'basic line plot with bounds, square aspect ratio',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => 'lines on both axes with labels, legends, titles',
|
tryplot( testname => 'lines on both axes with labels, legends, titles',
|
||||||
cmd => q{seq 5 | awk '{print 2*$1, $1*$1}'},
|
cmd => q{seq 5 | gawk '{print 2*$1, $1*$1}'},
|
||||||
options => [qw(--lines --points),
|
options => [qw(--lines --points),
|
||||||
'--legend', '0', 'data 0',
|
'--legend', '0', 'data 0',
|
||||||
'--title', "Test plot",
|
'--title', "Test plot",
|
||||||
@@ -369,7 +375,7 @@ tryplot( testname => 'lines on both axes with labels, legends, titles',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => 'lines on both axes with labels, legends, titles; different styles',
|
tryplot( testname => 'lines on both axes with labels, legends, titles; different styles',
|
||||||
cmd => q{seq 5 | awk '{print 2*$1, $1*$1}'},
|
cmd => q{seq 5 | gawk '{print 2*$1, $1*$1}'},
|
||||||
options => ['--legend', '0', 'data 0',
|
options => ['--legend', '0', 'data 0',
|
||||||
'--title', "Test plot",
|
'--title', "Test plot",
|
||||||
qw(--y2 1 --y2label y2 --xlabel x --ylabel y --y2max 30),
|
qw(--y2 1 --y2label y2 --xlabel x --ylabel y --y2max 30),
|
||||||
@@ -419,7 +425,7 @@ tryplot( testname => 'lines on both axes with labels, legends, titles; different
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => 'domain plot',
|
tryplot( testname => 'domain plot',
|
||||||
cmd => q{seq 5 | awk '{print 2*$1, $1*$1}'},
|
cmd => q{seq 5 | gawk '{print 2*$1, $1*$1}'},
|
||||||
options => [qw(--lines --points), '--domain'],
|
options => [qw(--lines --points), '--domain'],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
@@ -465,7 +471,7 @@ tryplot( testname => 'domain plot',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => 'dataid plot',
|
tryplot( testname => 'dataid plot',
|
||||||
cmd => q{seq 5 | awk '{print 2*$1, $1*$1}'},
|
cmd => q{seq 5 | gawk '{print 2*$1, $1*$1}'},
|
||||||
options => [qw(--lines --points),
|
options => [qw(--lines --points),
|
||||||
qw(--dataid --autolegend)],
|
qw(--dataid --autolegend)],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
@@ -512,7 +518,7 @@ tryplot( testname => 'dataid plot',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => '3d spiral with bounds, labels',
|
tryplot( testname => '3d spiral with bounds, labels',
|
||||||
cmd => q{seq 50 | awk '{print 2*cos($1/5), sin($1/5), $1}'},
|
cmd => q{seq 50 | gawk '{print 2*cos($1/5), sin($1/5), $1}'},
|
||||||
options => [qw(--lines --points),
|
options => [qw(--lines --points),
|
||||||
qw(--3d --domain --zmin -5 --zmax 45 --zlabel z),
|
qw(--3d --domain --zmin -5 --zmax 45 --zlabel z),
|
||||||
'--extracmds', 'set view 60,30'],
|
'--extracmds', 'set view 60,30'],
|
||||||
@@ -560,7 +566,7 @@ tryplot( testname => '3d spiral with bounds, labels',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => '3d spiral with bounds, labels, square xy aspect ratio',
|
tryplot( testname => '3d spiral with bounds, labels, square xy aspect ratio',
|
||||||
cmd => q{seq 50 | awk '{print 2*cos($1/5), sin($1/5), $1}'},
|
cmd => q{seq 50 | gawk '{print 2*cos($1/5), sin($1/5), $1}'},
|
||||||
options => [qw(--lines --points),
|
options => [qw(--lines --points),
|
||||||
qw(--3d --domain --zmin -5 --zmax 45 --zlabel z),
|
qw(--3d --domain --zmin -5 --zmax 45 --zlabel z),
|
||||||
'--extracmds', 'set view 60,30', '--square_xy'],
|
'--extracmds', 'set view 60,30', '--square_xy'],
|
||||||
@@ -608,7 +614,7 @@ tryplot( testname => '3d spiral with bounds, labels, square xy aspect ratio',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => 'Monotonicity check',
|
tryplot( testname => 'Monotonicity check',
|
||||||
cmd => q{seq 10 | awk '{print (NR-1)%5,NR}'},
|
cmd => q{seq 10 | gawk '{print (NR-1)%5,NR}'},
|
||||||
options => [qw(--lines --points --domain --monotonic)],
|
options => [qw(--lines --points --domain --monotonic)],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
@@ -655,7 +661,7 @@ EOF
|
|||||||
|
|
||||||
|
|
||||||
tryplot( testname => 'basic --timefmt plot',
|
tryplot( testname => 'basic --timefmt plot',
|
||||||
cmd => q{seq 5 | awk '{print strftime("%d %b %Y %T",1382249107+$1,1),$1}'},
|
cmd => q{seq 5 | gawk '{print strftime("%d %b %Y %T",1382249107+$1,1),$1}'},
|
||||||
options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S'],
|
options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S'],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
@@ -701,7 +707,7 @@ tryplot( testname => 'basic --timefmt plot',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => '--timefmt plot with bounds',
|
tryplot( testname => '--timefmt plot with bounds',
|
||||||
cmd => q{seq 5 | awk '{print strftime("%d %b %Y %T",1382249107+$1,1),$1}'},
|
cmd => q{seq 5 | gawk '{print strftime("%d %b %Y %T",1382249107+$1,1),$1}'},
|
||||||
options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S',
|
options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S',
|
||||||
'--xmin', '20 Oct 2013 06:05:00',
|
'--xmin', '20 Oct 2013 06:05:00',
|
||||||
'--xmax', '20 Oct 2013 06:05:20'],
|
'--xmax', '20 Oct 2013 06:05:20'],
|
||||||
@@ -749,7 +755,7 @@ tryplot( testname => '--timefmt plot with bounds',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => '--timefmt plot with --monotonic',
|
tryplot( testname => '--timefmt plot with --monotonic',
|
||||||
cmd => q{seq 10 | awk '{x=(NR-1)%5; print strftime("%d %b %Y %T",1382249107+x,1),$1}'},
|
cmd => q{seq 10 | gawk '{x=(NR-1)%5; print strftime("%d %b %Y %T",1382249107+x,1),$1}'},
|
||||||
options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S',
|
options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S',
|
||||||
'--monotonic'],
|
'--monotonic'],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
@@ -795,10 +801,57 @@ tryplot( testname => '--timefmt plot with --monotonic',
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
tryplot( testname => '--timefmt with custom rangesize',
|
||||||
|
cmd => q{seq 5 | gawk '{print strftime("%d %b %Y %T",1382249107+$1,1),$1,$1/10}'},
|
||||||
|
options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S',
|
||||||
|
qw(--with errorbars --rangesizeall 2)],
|
||||||
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
|
|
||||||
|
5.5 ++---------+-----------+----------+----------+----------+-----------+----------+---------**
|
||||||
|
+ + + + + + + + *
|
||||||
|
| *
|
||||||
|
5 ++ +A
|
||||||
|
| *
|
||||||
|
| *
|
||||||
|
| *
|
||||||
|
4.5 ++ **
|
||||||
|
| *** |
|
||||||
|
| * |
|
||||||
|
4 ++ A ++
|
||||||
|
| * |
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
3.5 ++ ++
|
||||||
|
| *** |
|
||||||
|
| * |
|
||||||
|
3 ++ A ++
|
||||||
|
| * |
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
2.5 ++ ++
|
||||||
|
| |
|
||||||
|
| *** |
|
||||||
|
2 ++ A ++
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
| |
|
||||||
|
1.5 ++ ++
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
1 A* ++
|
||||||
|
** |
|
||||||
|
| |
|
||||||
|
+ + + + + + + + +
|
||||||
|
0.5 ++---------+-----------+----------+----------+----------+-----------+----------+---------++
|
||||||
|
05:08 05:08 05:09 05:09 05:10 05:10 05:11 05:11 05:12
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
tryplot( testname => 'Error bars (using extraValuesPerPoint)',
|
tryplot( testname => 'Error bars (using extraValuesPerPoint)',
|
||||||
cmd => q{seq 5 | awk '{print $1,$1,$1/10}'},
|
cmd => q{seq 5 | gawk '{print $1,$1,$1/10}'},
|
||||||
options => [qw(--domain),
|
options => [qw(--domain),
|
||||||
qw(--extraValuesPerPoint 1 --curvestyle 0), 'with errorbars'],
|
qw(--extraValuesPerPoint 1 --with errorbars)],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
|
|
||||||
@@ -843,6 +896,103 @@ tryplot( testname => 'Error bars (using extraValuesPerPoint)',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
tryplot( testname => 'Error bars (using rangesizeall)',
|
||||||
|
cmd => q{seq 5 | gawk '{print $1,$1,$1/10}'},
|
||||||
|
options => [qw(--domain),
|
||||||
|
qw(--rangesizeall 2 --with errorbars)],
|
||||||
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
|
|
||||||
|
5.5 ++---------+-----------+----------+----------+----------+-----------+----------+---------**
|
||||||
|
+ + + + + + + + *
|
||||||
|
| *
|
||||||
|
5 ++ +A
|
||||||
|
| *
|
||||||
|
| *
|
||||||
|
| *
|
||||||
|
4.5 ++ **
|
||||||
|
| *** |
|
||||||
|
| * |
|
||||||
|
4 ++ A ++
|
||||||
|
| * |
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
3.5 ++ ++
|
||||||
|
| *** |
|
||||||
|
| * |
|
||||||
|
3 ++ A ++
|
||||||
|
| * |
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
2.5 ++ ++
|
||||||
|
| |
|
||||||
|
| *** |
|
||||||
|
2 ++ A ++
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
| |
|
||||||
|
1.5 ++ ++
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
1 A* ++
|
||||||
|
** |
|
||||||
|
| |
|
||||||
|
+ + + + + + + + +
|
||||||
|
0.5 ++---------+-----------+----------+----------+----------+-----------+----------+---------++
|
||||||
|
1 1.5 2 2.5 3 3.5 4 4.5 5
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
tryplot( testname => 'Error bars (using rangesize, rangesizeall)',
|
||||||
|
cmd => q{seq 5 | gawk '{print $1,"vert",$1,$1/10,"horiz",5-$1,$1-$1/5,$1+$1/20}'},
|
||||||
|
options => [qw(--domain --dataid),
|
||||||
|
qw(--rangesize vert 2 --rangesizeall 3 --with xerrorbars --style vert), 'with errorbars',
|
||||||
|
qw(--xmin 1 --xmax 5 --ymin 0.5 --ymax 5.5)],
|
||||||
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
|
|
||||||
|
+-----------+----------+-----------+----------+-----------+----------+-----------+---------**
|
||||||
|
+ + + + + + + + *
|
||||||
|
| *
|
||||||
|
5 ++ +A
|
||||||
|
| *
|
||||||
|
| *
|
||||||
|
| *
|
||||||
|
| **
|
||||||
|
| *** |
|
||||||
|
## * |
|
||||||
|
4 B# A ++
|
||||||
|
## * |
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
| |
|
||||||
|
| *** |
|
||||||
|
| # # * |
|
||||||
|
3 ++ #########B## A ++
|
||||||
|
| # # * |
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
| *** # # |
|
||||||
|
2 ++ A ##############B### ++
|
||||||
|
| * # # |
|
||||||
|
| *** |
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
| # # |
|
||||||
|
1 A* ##################B##### ++
|
||||||
|
** # # |
|
||||||
|
| |
|
||||||
|
+ + + + + + + + +
|
||||||
|
+-----------+----------+-----------+----------+-----------+----------+-----------+----------+
|
||||||
|
1 1.5 2 2.5 3 3.5 4 4.5 5
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
SKIP:
|
SKIP:
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -860,7 +1010,7 @@ skip "Skipping unreliable tests. Set RUN_ALL_TESTS environment variable to run t
|
|||||||
|
|
||||||
|
|
||||||
tryplot( testname => 'Histogram plot',
|
tryplot( testname => 'Histogram plot',
|
||||||
cmd => q{seq 50 | awk '{print $1*$1}'},
|
cmd => q{seq 50 | gawk '{print $1*$1}'},
|
||||||
options => [qw(--lines --points),
|
options => [qw(--lines --points),
|
||||||
qw(--histo 0 --binwidth 50 --ymin 0 --curvestyleall), 'with boxes'],
|
qw(--histo 0 --binwidth 50 --ymin 0 --curvestyleall), 'with boxes'],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
@@ -907,7 +1057,7 @@ tryplot( testname => 'Histogram plot',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => 'Cumulative histogram',
|
tryplot( testname => 'Cumulative histogram',
|
||||||
cmd => q{seq 50 | awk '{print $1*$1}'},
|
cmd => q{seq 50 | gawk '{print $1*$1}'},
|
||||||
options => [qw(--lines --points),
|
options => [qw(--lines --points),
|
||||||
qw(--histo 0 --histstyle cum --binwidth 50 --ymin 0 --curvestyleall), 'with boxes'],
|
qw(--histo 0 --histstyle cum --binwidth 50 --ymin 0 --curvestyleall), 'with boxes'],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
@@ -954,7 +1104,7 @@ tryplot( testname => 'Cumulative histogram',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => 'Circles',
|
tryplot( testname => 'Circles',
|
||||||
cmd => q{seq 5 | awk '{print $1,$1,$1/10}'},
|
cmd => q{seq 5 | gawk '{print $1,$1,$1/10}'},
|
||||||
options => [qw(--circles --domain)],
|
options => [qw(--circles --domain)],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
@@ -1008,7 +1158,7 @@ note( "Starting to run streaming tests. These will take several seconds each" );
|
|||||||
# points, and then "exit", so I should have two frames worth of data plotted. I
|
# points, and then "exit", so I should have two frames worth of data plotted. I
|
||||||
# pre-send a 0 so that the gnuplot autoscaling is always well-defined
|
# pre-send a 0 so that the gnuplot autoscaling is always well-defined
|
||||||
tryplot( testname => 'basic streaming test',
|
tryplot( testname => 'basic streaming test',
|
||||||
cmd => q{seq 500 | awk 'BEGIN{ print 0; } {print (NR==3)? "exit" : $0; fflush(); system("sleep 1.2");}'},
|
cmd => q{seq 500 | gawk 'BEGIN{ print 0; } {print (NR==3)? "exit" : $0; fflush(); system("sleep 1.2");}'},
|
||||||
options => [qw(--lines --points --stream)],
|
options => [qw(--lines --points --stream)],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
@@ -1094,7 +1244,7 @@ tryplot( testname => 'basic streaming test',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => 'basic streaming test, twice as fast',
|
tryplot( testname => 'basic streaming test, twice as fast',
|
||||||
cmd => q{seq 500 | awk 'BEGIN{ print 0; } {print (NR==3)? "exit" : $0; fflush(); system("sleep 0.6");}'},
|
cmd => q{seq 500 | gawk 'BEGIN{ print 0; } {print (NR==3)? "exit" : $0; fflush(); system("sleep 0.6");}'},
|
||||||
options => [qw(--lines --points --stream 0.4)],
|
options => [qw(--lines --points --stream 0.4)],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
@@ -1181,7 +1331,7 @@ EOF
|
|||||||
|
|
||||||
|
|
||||||
tryplot( testname => 'streaming with --xlen',
|
tryplot( testname => 'streaming with --xlen',
|
||||||
cmd => q{seq 500 | awk 'BEGIN{ print 0; } {print (NR==3)? "exit" : $0; fflush(); system("sleep 0.6");}'},
|
cmd => q{seq 500 | gawk 'BEGIN{ print 0; } {print (NR==3)? "exit" : $0; fflush(); system("sleep 0.6");}'},
|
||||||
options => [qw(--lines --points --stream 0.4 --xlen 1.1)],
|
options => [qw(--lines --points --stream 0.4 --xlen 1.1)],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
@@ -1267,7 +1417,7 @@ tryplot( testname => 'streaming with --xlen',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => 'streaming with --monotonic',
|
tryplot( testname => 'streaming with --monotonic',
|
||||||
cmd => q{seq 500 | awk '{if(NR==11) {print "exit";} else {x=(NR-1)%5; if(x==0) {print -1,-1;} print x,NR;}; fflush(); system("sleep 0.6");}'},
|
cmd => q{seq 500 | gawk '{if(NR==11) {print "exit";} else {x=(NR-1)%5; if(x==0) {print -1,-1;} print x,NR;}; fflush(); system("sleep 0.6");}'},
|
||||||
options => [qw(--lines --points --stream 0.4 --domain --monotonic)],
|
options => [qw(--lines --points --stream 0.4 --domain --monotonic)],
|
||||||
refplot => <<'EOF' );
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
@@ -1673,7 +1823,7 @@ tryplot( testname => 'streaming with --monotonic',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => '--timefmt streaming plot with --xlen',
|
tryplot( testname => '--timefmt streaming plot with --xlen',
|
||||||
cmd => q{seq 5 | awk 'BEGIN{ print strftime("%d %b %Y %T",1382249107-1,1),-4;} {if(NR==3) {print "exit";} else{ print strftime("%d %b %Y %T",1382249107+$1,1),$1;} fflush(); system("sleep 0.6")}'},
|
cmd => q{seq 5 | gawk 'BEGIN{ print strftime("%d %b %Y %T",1382249107-1,1),-4;} {if(NR==3) {print "exit";} else{ print strftime("%d %b %Y %T",1382249107+$1,1),$1;} fflush(); system("sleep 0.6")}'},
|
||||||
options => ['--points', '--lines',
|
options => ['--points', '--lines',
|
||||||
'--domain', '--timefmt', '%d %b %Y %H:%M:%S',
|
'--domain', '--timefmt', '%d %b %Y %H:%M:%S',
|
||||||
qw(--stream 0.4 --xlen 3)],
|
qw(--stream 0.4 --xlen 3)],
|
||||||
@@ -1761,7 +1911,7 @@ tryplot( testname => '--timefmt streaming plot with --xlen',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
tryplot( testname => '--timefmt streaming plot with --monotonic',
|
tryplot( testname => '--timefmt streaming plot with --monotonic',
|
||||||
cmd => q{seq 10 | awk '{x=(NR-1)%5; if(x==0) {print strftime("%d %b %Y %T",1382249107-1,-4),-4;} print strftime("%d %b %Y %T",1382249107+x,1),NR; fflush(); system("sleep 0.6")}'},
|
cmd => q{seq 10 | gawk '{x=(NR-1)%5; if(x==0) {print strftime("%d %b %Y %T",1382249107-1,-4),-4;} print strftime("%d %b %Y %T",1382249107+x,1),NR; fflush(); system("sleep 0.6")}'},
|
||||||
options => ['--points', '--lines',
|
options => ['--points', '--lines',
|
||||||
'--domain', '--timefmt', '%d %b %Y %H:%M:%S',
|
'--domain', '--timefmt', '%d %b %Y %H:%M:%S',
|
||||||
qw(--stream 0.4 --monotonic)],
|
qw(--stream 0.4 --monotonic)],
|
||||||
@@ -2177,7 +2327,7 @@ sub tryplot
|
|||||||
my %args = @_;
|
my %args = @_;
|
||||||
|
|
||||||
my @options = ('--exit',
|
my @options = ('--exit',
|
||||||
'--extracmds', 'unset grid',
|
qw(--unset grid),
|
||||||
'--terminal', 'dumb 100,40');
|
'--terminal', 'dumb 100,40');
|
||||||
unshift @options, @{$args{options}};
|
unshift @options, @{$args{options}};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user