diff --git a/Changes b/Changes index eba3ab1..491dfd7 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,17 @@ +feedgnuplot (1.25) unstable; urgency=low + + * Added test suite + * Added initial support for --timefmt. Currently time/date data is + supported only at the x-axis domain + * Added --exit option for force feedgnuplot to return even if gnuplot + may not yet be done rendering (patch by Eric Schulte) + * Reformatted the documentation + * y2-axis curves no longer have a thicker line by default + * --hardcopy now handles piped output (gnuplot 'set output |process' + syntax) + + -- Dima Kogan Sun, 20 Oct 2013 00:09:36 -0700 + feedgnuplot (1.24) unstable; urgency=low * Fixed regression in --monotonic. This works again now diff --git a/MANIFEST b/MANIFEST index 7a47fbf..76dee53 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,7 +1,7 @@ Makefile.PL MANIFEST bin/feedgnuplot -t/00-load.t t/manifest.t +t/plots.t Changes LICENSE diff --git a/Makefile.PL b/Makefile.PL index 3b28356..584be4d 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -63,7 +63,7 @@ WriteMakefile : ()), PL_FILES => {}, EXE_FILES => [ 'bin/feedgnuplot' ], - PREREQ_PM => { 'Test::Script::Run' => 0}, + BUILD_REQUIRES => { 'String::ShellQuote' => 0}, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'feedgnuplot-*' }, ); diff --git a/bin/feedgnuplot b/bin/feedgnuplot index f7c8dee..3616f5c 100755 --- a/bin/feedgnuplot +++ b/bin/feedgnuplot @@ -13,7 +13,7 @@ use Thread::Queue; use Pod::Usage; use Time::Piece; -my $VERSION = 1.24; +my $VERSION = 1.25; my %options; interpretCommandline(); @@ -59,6 +59,8 @@ if($options{stream}) { chomp; + last if /^exit/; + # 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 @@ -163,8 +165,8 @@ sub interpretCommandline if ( defined $options{hardcopy} && defined $options{stream} ) { - print STDERR "Warning: since we're making a hardcopy, I'm disabling streaming\n"; - delete $options{stream}; + print STDERR "--stream doesn't make sense together with --hardcopy\n"; + exit -1; } # parse stream option. Allowed only numbers >= 0 or 'trigger'. After this code @@ -245,6 +247,12 @@ sub interpretCommandline print STDERR "--3d does not make sense with histograms\n"; exit -1; } + + if ( defined $options{circles} ) + { + print STDERR "--3d does not make sense with circles (gnuplot doesn't support this)\n"; + exit -1; + } } else { @@ -306,6 +314,17 @@ sub interpretCommandline $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 + # and strftime, and those are integer-only + if( defined $options{xlen} ) + { + if( $options{xlen} - int($options{xlen}) ) + { + say STDERR "When streaming --xlen MUST be an integer. Rounding up to the nearest second"; + $options{xlen} = 1 + int($options{xlen}); + } + } } } @@ -400,11 +419,15 @@ sub mainThread my $outputfile; my $outputfileType; - if( $options{hardcopy}) + if( defined $options{hardcopy}) { $outputfile = $options{hardcopy}; - $outputfile =~ /\.(eps|ps|pdf|png|svg)$/i; - $outputfileType = $1 ? lc $1 : ''; + if( $outputfile =~ /^[^|] # starts with anything other than | + .* # stuff in the middle + \.(eps|ps|pdf|png|svg)$/ix) # ends with a known extension + { + $outputfileType = lc $1; + } my %terminalOpts = ( eps => 'postscript solid color enhanced eps', @@ -413,8 +436,12 @@ sub mainThread png => 'png size 1280,1024', svg => 'svg'); - $options{terminal} ||= $terminalOpts{$outputfileType} - if $terminalOpts{$outputfileType}; + if( !defined $options{terminal} && + defined $outputfileType && + $terminalOpts{$outputfileType} ) + { + $options{terminal} = $terminalOpts{$outputfileType}; + } die "Asked to plot to file '$outputfile', but I don't know which terminal to use, and no --terminal given" unless $options{terminal}; @@ -493,7 +520,7 @@ sub mainThread { foreach (@{$options{y2}}) { - addCurveOption($_, 'axes x1y2 linewidth 3'); + addCurveOption($_, 'axes x1y2'); } } @@ -574,15 +601,25 @@ sub mainThread { next if /^#/o; - if( $options{stream} && /^clear/o ) - { clearCurves(); } - - elsif( $options{stream} && /^replot/o ) + if( $options{stream} ) { - # /timertick/ determines if the timer was the source of the replot - replot( $domain0_numeric, /timertick/ ); + if(/^clear/o ) + { + clearCurves(); + next; + } + + if(/^replot/o ) + { + # /timertick/ determines if the timer was the source of the replot + replot( $domain0_numeric, /timertick/ ); + next; + } + + # /exit/ is handled in the data-reading thread } - elsif(! /^replot/o) + + if(! /^replot/o) { # parse the incoming data lines. The format is # x id0 dat0 id1 dat1 .... @@ -649,16 +686,29 @@ sub mainThread } } + # if we were streaming, we're now done! + if( $options{stream} ) + { + return; + } + # finished reading in all. Plot what we have plotStoredData(); - if ( $options{hardcopy}) + if ( defined $options{hardcopy}) { print PIPE "set output\n"; - # sleep until the plot file exists, and it is closed. Sometimes the output is - # still being written at this point - usleep(100_000) until -e $outputfile; - usleep(100_000) until(system("fuser -s \"$outputfile\"")); + + # 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 + # '|', 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 + if( $options{hardcopy} !~ /^\|/ ) + { + usleep(100_000) until -e $outputfile; + usleep(100_000) until(system("fuser -s \"$outputfile\"")); + } print "Wrote output to $outputfile\n"; return; @@ -1008,14 +1058,6 @@ instead of I as a function of I). Thus the first 2 values on each line are interpreted as the domain instead of just 1. The rest of the processing happens the same way as before. -=head3 Special data commands - -Other than the raw data, 2 special commands are interpreted if they appear in -the input. These are C and C. If a line of data begins with -C and we're plotting in realtime with C<--stream>, the plot will be -refreshed immediately. If a line of data begins with C, the plot is -cleared, to be re-filled with any data following the C. - =head3 Time/date data If the input data domain is a time/date, this can be interpreted with @@ -1030,7 +1072,7 @@ given, some other options act a little bit differently: =item -C<--xlen> is in seconds +C<--xlen> is an I in seconds =item @@ -1052,6 +1094,10 @@ C<--timefmt>. Example: This plots the 'idle' CPU consumption against time. +Note that while gnuplot supports the time/date on any axis, I +currently supports it I as the x-axis domain. This may change in the +future. + =head2 Real-time streaming data To plot real-time data, pass in the C<--stream [refreshperiod]> option. Data @@ -1060,14 +1106,41 @@ C seconds. If the period isn't specified, a 1Hz refresh rate is used. To refresh at specific intervals indicated by the data, set the refreshperiod to 0 or to 'trigger'. The plot will then I be refreshed when a data line 'replot' is received. This 'replot' command works in both triggered -and timed modes, but in triggered mode, it's the only way to replot. +and timed modes, but in triggered mode, it's the only way to replot. Look in +L for more information. To plot only the most recent data (instead of I the data), C<--xlen windowsize> can be given. This will create an constantly-updating, scrolling view of the recent past. C should be replaced by the desired length of the domain window to plot, in domain units (passed-in values if C<--domain> or line numbers otherwise). If the domain is a time/date via C<--timefmt>, then -C is in seconds. +C is and I in seconds. + +=head3 Special data commands + +If we are reading streaming data, the input stream can contain special commands +in addition to the raw data. Feedgnuplot looks for these at the start of every +input line. If a command is detected, the rest of the line is discarded. These +commands are + +=over + +=item C + +This command refreshes the plot right now, instead of waiting for the next +refresh time indicated by the timer. This command works in addition to the timed +refresh, as indicated by C<--stream [refreshperiod]>. + +=item C + +This command clears out the current data in the plot. The plotting process +continues, however, to any data following the C. + +=item C + +This command causes feedgnuplot to exit. + +=back =head2 Hardcopy output @@ -1218,7 +1291,7 @@ Interpret the X data as a time/date, parsed with the given format 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 -extraValuesPerPoint +C<--extraValuesPerPoint> =item @@ -1226,8 +1299,8 @@ extraValuesPerPoint Plot the data as it comes in, in realtime. If period is given, replot every period seconds. If no period is given, replot at 1Hz. If the period is given as -0 or 'trigger', replot ONLY when the incoming data dictates this. See the -"Real-time streaming data" section of the man page. +0 or 'trigger', replot I when the incoming data dictates this. See the +L section of the man page. =item @@ -1246,43 +1319,20 @@ Do [not] draw points --circles Plot with circles. This requires a radius be specified for each point. -Automatically increments extraValuesPerPoint +Automatically increments C<--extraValuesPerPoint). C supported for 3d +plots. =item ---xlabel xxx - -Set x-axis label - -=item - ---ylabel xxx - -Set y-axis label - -=item - ---y2label xxx - -Set y2-axis label. Does not apply to 3d plots - -=item - ---zlabel xxx - -Set y-axis label. Only applies to 3d plots - -=item - ---title xxx +--title xxx Set the title of the plot =item ---legend curveID lege +--legend curveID legend -nd Set the label for a curve plot. Use this option multiple times for multiple +Set the label for a curve plot. Use this option multiple times for multiple curves. With --dataid, curveID is the ID. Otherwise, it's the index of the curve, starting at 0 @@ -1302,63 +1352,37 @@ to 0 to plot ALL the data. Does not make sense with 3d plots. Implies =item ---xmin xxx +--xmin/xmax/ymin/ymax/y2min/y2max/zmin/zmax xxx -Set the range for the x axis. These are ignored in a streaming plot +Set the range for the given axis. These x-axis bounds are ignored in a streaming +plot. The y2-axis bound do not apply in 3d plots. The z-axis bounds apply +I to 3d plots or colormaps. =item ---xmax xxx +--xlabel/ylabel/y2label/zlabel xxx -Set the range for the x axis. These are ignored in a streaming plot +Label the given axis. The y2-axis label does not apply to 3d plots while the +z-axis label applies I to 3d plots. =item ---ymin xxx - -Set the range for the y axis. - -=item - ---ymax xxx - -Set the range for the y axis. - -=item - ---y2min xxx - -Set the range for the y2 axis. Does not apply to 3d plots. - -=item - ---y2max xxx - -Set the range for the y2 axis. Does not apply to 3d plots. - -=item - ---zmin xxx - -Set the range for the z axis. Only applies to 3d plots or colormaps. - -=item - ---zmax xxx - -Set the range for the z axis. Only applies to 3d plots or colormaps. - -=item - ---y2 xxx +--y2 xxx Plot the data specified by this curve ID on the y2 axis. Without --dataid, the ID is just an ordered 0-based index. Does not apply to 3d plots. Can be passed -multiple times, or passed a comma-separated list +multiple times, or passed a comma-separated list. By default the y2-axis curves +look the same as the y-axis ones. I.e. the viewer of the resulting plot has to +be told which is which via an axes label, legend, etc. Prior to version 1.25 of +feedgnuplot the curves plotted on the y2 axis were drawn with a thicker line. +This is no longer the case, but that behavior can be brought back by passing +something like + + --y2 curveid --curvestyle curveid 'linewidth 3' =item ---histogram curveID +--histogram curveID Set up a this specific curve to plot a histogram. The bin width is given with @@ -1518,13 +1542,13 @@ Looks at wlan0 on Linux. gawk '/wlan0/ {if(b) {print $2-b; fflush()} b=$2}' | feedgnuplot --lines --stream --xlen 10 --ylabel 'Bytes/sec' --xlabel seconds -=head2 Realtime plot of battery charge +=head2 Realtime plot of battery charge in respect to time Uses the result of the C command. $ while true; do acpi; sleep 15; done | - perl -nE 'BEGIN{ $| = 1; } /([0-9]*)%/; say join(" ", $./4, $1);' | - feedgnuplot --stream --ymin 0 --ymax 100 --domain --xlabel 'Time (seconds)' --ylabel "Battery charge (%)" + perl -nE 'BEGIN{ $| = 1; } /([0-9]*)%/; say join(" ", time(), $1);' | + feedgnuplot --stream --ymin 0 --ymax 100 --lines --domain --xlabel 'Time' --timefmt '%s' --ylabel "Battery charge (%)" =head2 Realtime plot of temperatures in an IBM Thinkpad diff --git a/t/00-load.t b/t/00-load.t deleted file mode 100644 index 0a99850..0000000 --- a/t/00-load.t +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/perl - -# require a threaded perl for my tests. This block lifted verbatim from the cpantesters wiki -BEGIN { - use Config; - if (! $Config{'useithreads'}) { - print("1..0 # Skip: Perl not compiled with 'useithreads'\n"); - exit(0); - } -} - -use Test::More tests => 1; -use Test::Script::Run; - -run_ok( 'feedgnuplot', ['--help'], 'feedgnuplot can run'); - diff --git a/t/plots.t b/t/plots.t new file mode 100644 index 0000000..b351999 --- /dev/null +++ b/t/plots.t @@ -0,0 +1,2175 @@ +#!/usr/bin/perl + +# This tests various features of feedgnuplot. Note that the tests look at actual +# plot output using the 'dumb' terminal, so any changes in gnuplot itself that +# change the way the output looks will show up as test failures. Currently the +# reference plots come from gnuplot 4.6.4, and I make sure this is the version +# we're testing with + + +# require a threaded perl for my tests. This block lifted verbatim from the cpantesters wiki +BEGIN { + use Config; + if (! $Config{'useithreads'}) { + print("1..0 # Skip: Perl not compiled with 'useithreads'\n"); + exit(0); + } + + open(my $pipe, 'gnuplot --version |'); + if( !$pipe ) + { + print("1..0 # Skip: gnuplot not installed. Tests require ver. 4.6.4; feedgnuplot works with any.\n"); + exit(0); + } + + my $gnuplotVersion = <$pipe>; + chomp $gnuplotVersion; + if ($gnuplotVersion ne "gnuplot 4.6 patchlevel 4") + { + print("1..0 # Skip: tests require gnuplot 4.6.4. Instead I detected '$gnuplotVersion'.\n"); + exit(0); + } +} + +use Test::More tests => 52; +use File::Temp 'tempfile'; +use IPC::Run 'run'; +use String::ShellQuote; +use File::Basename; + +tryplot( testname => 'basic line plot', + cmd => 'seq 5', + options => [qw(--lines --points)], + refplot => <<'EOF' ); + + + 5 ++---------+-----------+----------+----------+----------+-----------+----------+---------*A + + + + + + + + + ** + + | *** | + | ** | + 4.5 ++ *** ++ + | ** | + | ** | + | *** | + | ** | + 4 ++ *A* ++ + | *** | + | *** | + | *** | + 3.5 ++ ** ++ + | *** | + | *** | + | *** | + 3 ++ *A* ++ + | ** | + | *** | + | ** | + | *** | + 2.5 ++ ** ++ + | ** | + | *** | + | ** | + 2 ++ *A* ++ + | ** | + | *** | + | ** | + | *** | + 1.5 ++ *** ++ + | ** | + | *** | + + ** + + + + + + + + + 1 A*---------+-----------+----------+----------+----------+-----------+----------+---------++ + 1 1.5 2 2.5 3 3.5 4 4.5 5 + +EOF + +tryplot( testname => 'basic line plot to piped hardcopy', + cmd => 'seq 5', + options => [qw(--lines --points), + '--hardcopy', '|cat'], + refplot => <<'EOF' ); + + + 5 ++---------+-----------+----------+----------+----------+-----------+----------+---------*A + + + + + + + + + ** + + | *** | + | ** | + 4.5 ++ *** ++ + | ** | + | ** | + | *** | + | ** | + 4 ++ *A* ++ + | *** | + | *** | + | *** | + 3.5 ++ ** ++ + | *** | + | *** | + | *** | + 3 ++ *A* ++ + | ** | + | *** | + | ** | + | *** | + 2.5 ++ ** ++ + | ** | + | *** | + | ** | + 2 ++ *A* ++ + | ** | + | *** | + | ** | + | *** | + 1.5 ++ *** ++ + | ** | + | *** | + + ** + + + + + + + + + 1 A*---------+-----------+----------+----------+----------+-----------+----------+---------++ + 1 1.5 2 2.5 3 3.5 4 4.5 5 + +Wrote output to |cat +EOF + +tryplot( testname => 'basic lines-only plot', + cmd => 'seq 5', + options => [qw(--lines)], + refplot => <<'EOF' ); + + + 5 ++---------+-----------+----------+----------+----------+-----------+----------+---------** + + + + + + + + + ** + + | *** | + | ** | + 4.5 ++ *** ++ + | ** | + | ** | + | *** | + | ** | + 4 ++ *** ++ + | *** | + | *** | + | *** | + 3.5 ++ ** ++ + | *** | + | *** | + | *** | + 3 ++ *** ++ + | ** | + | *** | + | ** | + | *** | + 2.5 ++ ** ++ + | ** | + | *** | + | ** | + 2 ++ *** ++ + | ** | + | *** | + | ** | + | *** | + 1.5 ++ *** ++ + | ** | + | *** | + + ** + + + + + + + + + 1 **---------+-----------+----------+----------+----------+-----------+----------+---------++ + 1 1.5 2 2.5 3 3.5 4 4.5 5 + +EOF + +tryplot( testname => 'basic points-only plot', + cmd => 'seq 5', + options => [qw(--points)], + refplot => <<'EOF' ); + + + 5 ++---------+-----------+----------+----------+----------+-----------+----------+---------+A + + + + + + + + + + + | | + | | + 4.5 ++ ++ + | | + | | + | | + | | + 4 ++ A ++ + | | + | | + | | + 3.5 ++ ++ + | | + | | + | | + 3 ++ A ++ + | | + | | + | | + | | + 2.5 ++ ++ + | | + | | + | | + 2 ++ A ++ + | | + | | + | | + | | + 1.5 ++ ++ + | | + | | + + + + + + + + + + + 1 A+---------+-----------+----------+----------+----------+-----------+----------+---------++ + 1 1.5 2 2.5 3 3.5 4 4.5 5 + +EOF + +tryplot( testname => 'basic line plot with bounds', + cmd => 'seq 5', + options => [qw(--lines --points), + qw(--xmin -10.5 --xmax 4.5 --ymin -0.5 --ymax 5.5)], + refplot => <<'EOF' ); + + + +--+-----------+------------+-----------+-----------+-----------+------------+-----------+--+ + | + + + + + + + + | + | | + 5 ++ ++ + | | + | | + | * + | *| + | * | + 4 ++ A ++ + | * | + | * | + | * | + | * | + | * | + 3 ++ A ++ + | * | + | ** | + | * | + | * | + 2 ++ A ++ + | * | + | * | + | * | + | * | + | * | + 1 ++ A ++ + | | + | | + | | + | | + | | + 0 ++ ++ + | | + | + + + + + + + + | + +--+-----------+------------+-----------+-----------+-----------+------------+-----------+--+ + -10 -8 -6 -4 -2 0 2 4 + +EOF + +tryplot( testname => 'basic line plot with bounds, square aspect ratio', + cmd => 'seq 5', + options => [qw(--lines --points), + qw(--xmin -10.5 --xmax 4.5 --ymin -0.5 --ymax 5.5 --square)], + refplot => <<'EOF' ); + + + +--+-----------+----------+-----------+-----------+-----------+----------+-----------+--+ + | + + + + + + + + | + | | + 5 ++ ++ + | | + | | + | * + | *| + | * | + 4 ++ A ++ + | * | + | * | + | * | + | * | + | * | + 3 ++ A ++ + | * | + | ** | + | * | + | * | + 2 ++ A ++ + | * | + | * | + | * | + | * | + | * | + 1 ++ A ++ + | | + | | + | | + | | + | | + 0 ++ ++ + | | + | + + + + + + + + | + +--+-----------+----------+-----------+-----------+-----------+----------+-----------+--+ + -10 -8 -6 -4 -2 0 2 4 + +EOF + +tryplot( testname => 'lines on both axes with labels, legends, titles', + cmd => q{seq 5 | awk '{print 2*$1, $1*$1}'}, + options => [qw(--lines --points), + '--legend', '0', 'data 0', + '--title', "Test plot", + qw(--y2 1 --y2label y2 --xlabel x --ylabel y --y2max 30)], + refplot => <<'EOF' ); + + Test plot + y2 + 10 ++---------+----------+---------+----------+----------+----------+---------+---------*A 30 + + + + + + + + data 0 **A*** + + | *** | + | *** | + 9 ++ ** | + | *** #B 25 + | *** ## | + | ** ## | + 8 ++ *A* ## | + | *** ## | + | ** ## | + | *** ## ++ 20 + 7 ++ *** ## | + | *** ## | + | ** ## | + | *** #B# | + 6 ++ *A* ### ++ 15 + | ** ## | + | ** ### | + | *** ### | + | ** ### | + 5 ++ ** ## | + | *** ### ++ 10 + | ** #B# | + | ** #### | + 4 ++ *A* ### | + | *** #### | + | ** ### ++ 5 + | *** #### | + 3 ++ *** ###B# | + | *** ######## | + | #**#### | + B#*** + + + + + + + + + 2 A*---------+----------+---------+----------+----------+----------+---------+---------++ 0 + 1 1.5 2 2.5 3 3.5 4 4.5 5 + x + +EOF + +tryplot( testname => 'lines on both axes with labels, legends, titles; different styles', + cmd => q{seq 5 | awk '{print 2*$1, $1*$1}'}, + options => ['--legend', '0', 'data 0', + '--title', "Test plot", + qw(--y2 1 --y2label y2 --xlabel x --ylabel y --y2max 30), + '--curvestyle', '0', 'with lines', + '--curvestyle', '1', 'with points ps 3 pt 7'], + refplot => <<'EOF' ); + + Test plot + y2 + 10 ++---------+----------+---------+----------+----------+----------+---------+---------** 30 + + + + + + + + data 0 ****** + + | *** | + | *** | + 9 ++ ** | + | *** +G 25 + | *** | + | ** | + 8 ++ *** | + | *** | + | ** | + | *** ++ 20 + 7 ++ *** | + | *** | + | ** | + | *** G | + 6 ++ *** ++ 15 + | ** | + | ** | + | *** | + | ** | + 5 ++ ** | + | *** ++ 10 + | ** G | + | ** | + 4 ++ *** | + | *** | + | ** ++ 5 + | *** | + 3 ++ *** G | + | *** | + | ** | + G *** + + + + + + + + + 2 **---------+----------+---------+----------+----------+----------+---------+---------++ 0 + 1 1.5 2 2.5 3 3.5 4 4.5 5 + x + +EOF + +tryplot( testname => 'domain plot', + cmd => q{seq 5 | awk '{print 2*$1, $1*$1}'}, + options => [qw(--lines --points), '--domain'], + refplot => <<'EOF' ); + + + 25 ++---------+-----------+----------+-----------+----------+----------+-----------+---------+A + + + + + + + + + **+ + | ** | + | ** | + | * | + | ** | + | ** | + 20 ++ ** ++ + | ** | + | * | + | ** | + | ** | + | ** | + | *A | + 15 ++ ** ++ + | *** | + | ** | + | *** | + | ** | + | ** | + | *** | + 10 ++ ** ++ + | *A* | + | *** | + | **** | + | *** | + | *** | + | **** | + 5 ++ *** ++ + | **A* | + | **** | + | ***** | + | ***** | + | **** | + A** + + + + + + + + + 0 ++---------+-----------+----------+-----------+----------+----------+-----------+---------++ + 2 3 4 5 6 7 8 9 10 + +EOF + +tryplot( testname => 'dataid plot', + cmd => q{seq 5 | awk '{print 2*$1, $1*$1}'}, + options => [qw(--lines --points), + qw(--dataid --autolegend)], + refplot => <<'EOF' ); + + + 25 ++---------+-----------+----------+-----------+----------+----------+-----------+---------+E + + + + + + + + + 2 **A*** + + | 4 ##B### | + | 6 $$C$$$ | + | 8 %%D%%% | + | 10 @@E@@@ | + | | + 20 ++ ++ + | | + | | + | | + | | + | | + | D | + 15 ++ ++ + | | + | | + | | + | | + | | + | | + 10 ++ ++ + | C | + | | + | | + | | + | | + | | + 5 ++ ++ + | B | + | | + | | + | | + | | + A + + + + + + + + + 0 ++---------+-----------+----------+-----------+----------+----------+-----------+---------++ + 1 1.5 2 2.5 3 3.5 4 4.5 5 + +EOF + +tryplot( testname => '3d spiral with bounds, labels', + cmd => q{seq 50 | awk '{print 2*cos($1/5), sin($1/5), $1}'}, + options => [qw(--lines --points), + qw(--3d --domain --zmin -5 --zmax 45 --zlabel z), + '--extracmds', 'set view 60,30'], + refplot => <<'EOF' ); + + + + + + + + ***A****A****A****A***A** + * **A** + **A***A* + *A* + *A + * + + A + 40 |+ **A****A****A****A***A** A + | **A **A****A** A + 30 |+ A*A *A** *A + | A *AA* + z 20 |+ AA** **A* *A* + | A**A***A***A****A*****A***A****A****A* AA + 10 |+ -+---- A + | ---- +--------- A + 0 |+ ---+ + --------- + | ---++ +-+--------- + | ----++ + --------- + | ---+ + ----- 1 + | ---+ --- 0.8 + | ----+ --++ 0.6 + +-+++--------- --- 0.20.4 + -2 -1.5 ++ +--------- --- 0 + -1 + ++ --+------ --- -0.2 + -0.5 0 + ++ --------- ---+ -0.4 + 0.5 1 ++ -+--- --0.8.6 + 1.5 + +-1+ + 2 + + + + + +EOF + +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}'}, + options => [qw(--lines --points), + qw(--3d --domain --zmin -5 --zmax 45 --zlabel z), + '--extracmds', 'set view 60,30', '--square_xy'], + refplot => <<'EOF' ); + + + + + + + + + *AA* + AA*A + A + + A*A + 40 |+ A + | A + 30 |+ A + | AAAAA* A + z 20 |+AA AA A + | AA* A*A AA + | AA*AAA*AA*A + 10 |+ AAA + 0 |+ A + | A + | +- A + | -++--- + | --+ +--- + |-++ +--- + +++-- --- + -21.5+--- +- 1 + -10.5--- + 0.6 + 0 +--- + 024 + 0.5 ++-0.4 + 1.521.8 + + + + + + + + +EOF + +tryplot( testname => 'Histogram plot', + cmd => q{seq 50 | awk '{print $1*$1}'}, + options => [qw(--lines --points), + qw(--histo 0 --binwidth 50 --ymin 0 --curvestyleall), 'with boxes'], + refplot => <<'EOF' ); + + + 4 ++----------****----------+------------+-----------+------------+------------+-----------++ + + *+** + + + + + + + | * ** | + | * ** | + 3.5 ++ * ** ++ + | * ** | + | * ** | + | * ** | + | * ** | + 3 ++ * *** ++ + | * *** | + | * *** | + | * *** | + 2.5 ++ * *** ++ + | * *** | + | * *** | + | * *** | + 2 ++ * **** *** ++ + | * **** *** | + | * **** *** | + | * **** *** | + | * **** *** | + 1.5 ++ * **** *** ++ + | * **** *** | + | * **** *** | + | * **** *** | + 1 ++ * ************************** ******** ************************** ** ++ + | * **** *** **** *** **** *** **** *** **** *** **** *** **** *** ** | + | * **** *** **** *** **** *** **** *** **** *** **** *** **** *** ** | + | * **** *** **** *** **** *** **** *** **** *** **** *** **** *** ** | + | * **** *** **** *** **** *** **** *** **** *** **** *** **** *** ** | + 0.5 ++ * **** *** **** *** **** *** **** *** **** *** **** *** **** *** ** ++ + | * **** *** **** *** **** *** **** *** **** *** **** *** **** *** ** | + | * **** *** **** *** **** *** **** *** **** *** **** *** **** *** ** | + + *+**** *** **** *** **** *** **** *** **** *** **** *** **** *** ** + + 0 ++----------****************************-********-**************************-**----------++ + -500 0 500 1000 1500 2000 2500 3000 + +EOF + +tryplot( testname => 'Cumulative histogram', + cmd => q{seq 50 | awk '{print $1*$1}'}, + options => [qw(--lines --points), + qw(--histo 0 --histstyle cum --binwidth 50 --ymin 0 --curvestyleall), 'with boxes'], + refplot => <<'EOF' ); + + + 50 ++-----------+------------+------------+------------+------------+-----------***----------++ + + + + + + + ** ***+* + + | **** *** * | + | *** **** *** * | + | ** *** **** *** * | + | ***** *** **** *** * | + | **** *** *** **** *** * | + 40 ++ ** **** *** *** **** *** * ++ + | ****** **** *** *** **** *** * | + | ***** *** **** *** *** **** *** * | + | *** *** *** **** *** *** **** *** * | + | ****** *** *** **** *** *** **** *** * | + | ** **** *** *** **** *** *** **** *** * | + | ****** **** *** *** **** *** *** **** *** * | + 30 ++ *** *** **** *** *** **** *** *** **** *** * ++ + | ****** *** **** *** *** **** *** *** **** *** * | + | *** *** *** **** *** *** **** *** *** **** *** * | + | ****** *** *** **** *** *** **** *** *** **** *** * | + | ** **** *** *** **** *** *** **** *** *** **** *** * | + | *** **** *** *** **** *** *** **** *** *** **** *** * | + | ****** **** *** *** **** *** *** **** *** *** **** *** * | + 20 ++ *** *** **** *** *** **** *** *** **** *** *** **** *** * ++ + | ****** *** **** *** *** **** *** *** **** *** *** **** *** * | + | ** *** *** **** *** *** **** *** *** **** *** *** **** *** * | + | *** *** *** **** *** *** **** *** *** **** *** *** **** *** * | + | **** *** *** **** *** *** **** *** *** **** *** *** **** *** * | + | ****** *** *** **** *** *** **** *** *** **** *** *** **** *** * | + | ** **** *** *** **** *** *** **** *** *** **** *** *** **** *** * | + 10 ++ ** **** *** *** **** *** *** **** *** *** **** *** *** **** *** * ++ + | *** **** *** *** **** *** *** **** *** *** **** *** *** **** *** * | + | *** **** *** *** **** *** *** **** *** *** **** *** *** **** *** * | + | *** **** *** *** **** *** *** **** *** *** **** *** *** **** *** * | + | ***** **** *** *** **** *** *** **** *** *** **** *** *** **** *** * | + | * *** **** *** *** **** *** *** **** *** *** **** *** *** **** *** * | + + *+*** **** ***+*** **** ***+*** **** ***+*** **** ***+*** **** ***+* + + 0 ++----------********************************************-********+***-****-*****----------++ + -500 0 500 1000 1500 2000 2500 3000 + +EOF + +tryplot( testname => 'Circles', + cmd => q{seq 5 | awk '{print $1,$1,$1/10}'}, + options => [qw(--circles --domain)], + refplot => <<'EOF' ); + + + 5 ++-------+--------+--------+--------+--------+--------+--------+--------******************* + + + + + + + + + * + *+ + | * * *| + | ******** * *| + 4.5 ++ ** ** * *+ + | ** ** ** **| + | ** ** ** ** | + | * * ** ** | + | * * ** ** | + 4 ++ * ** ********** ++ + | * * | + | * * | + | * * * | + 3.5 ++ ****** ** ** ++ + | * * ** ** | + | * * ** ** | + | * * ******** | + 3 ++ * ** ++ + | * * | + | * * | + | * * | + | * * | + 2.5 ++ * ****** ++ + | ****** | + | ** ** | + | * * | + 2 ++ * ** ++ + | * ** | + | * * | + | ** ** | + | ****** | + 1.5 ++ ++ + | | + | * | + + **** + + + + + + + + + + 1 ++-----*-+**------+--------+--------+--------+--------+--------+--------+--------+-------++ + 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 + +EOF + +tryplot( testname => 'Error bars (using extraValuesPerPoint)', + cmd => q{seq 5 | awk '{print $1,$1,$1/10}'}, + options => [qw(--domain), + qw(--extraValuesPerPoint 1 --curvestyle 0), '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 => 'Monotonicity check', + cmd => q{seq 10 | awk '{print (NR-1)%5,NR}'}, + options => [qw(--lines --points --domain --monotonic)], + refplot => <<'EOF' ); + + + 10 ++---------+-----------+----------+----------+----------+-----------+----------+---------*A + + + + + + + + + ** + + | *** | + | ** | + 9.5 ++ *** ++ + | ** | + | ** | + | *** | + | ** | + 9 ++ *A* ++ + | *** | + | *** | + | *** | + 8.5 ++ ** ++ + | *** | + | *** | + | *** | + 8 ++ *A* ++ + | ** | + | *** | + | ** | + | *** | + 7.5 ++ ** ++ + | ** | + | *** | + | ** | + 7 ++ *A* ++ + | ** | + | *** | + | ** | + | *** | + 6.5 ++ *** ++ + | ** | + | *** | + + ** + + + + + + + + + 6 A*---------+-----------+----------+----------+----------+-----------+----------+---------++ + 0 0.5 1 1.5 2 2.5 3 3.5 4 + +EOF + + +tryplot( testname => 'basic --timefmt plot', + cmd => q{seq 5 | awk '{print strftime("%d %b %Y %T",1382249107+$1,1),$1}'}, + options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S'], + refplot => <<'EOF' ); + + + 5 ++---------+-----------+----------+----------+----------+-----------+----------+---------+A + + + + + + + + + + + | | + | | + 4.5 ++ ++ + | | + | | + | | + | | + 4 ++ A ++ + | | + | | + | | + 3.5 ++ ++ + | | + | | + | | + 3 ++ A ++ + | | + | | + | | + | | + 2.5 ++ ++ + | | + | | + | | + 2 ++ A ++ + | | + | | + | | + | | + 1.5 ++ ++ + | | + | | + + + + + + + + + + + 1 A+---------+-----------+----------+----------+----------+-----------+----------+---------++ + 05:08 05:08 05:09 05:09 05:10 05:10 05:11 05:11 05:12 + +EOF + +tryplot( testname => '--timefmt plot with bounds', + cmd => q{seq 5 | awk '{print strftime("%d %b %Y %T",1382249107+$1,1),$1}'}, + options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S', + '--xmin', '20 Oct 2013 06:05:00', + '--xmax', '20 Oct 2013 06:05:20'], + refplot => <<'EOF' ); + + + 5 ++---+---+----+---+----+---+----+---+----+---+----+---A----+---+----+---+----+---+----+--++ + + + + + + + | | + | | + 4.5 ++ ++ + | | + | | + | | + | | + 4 ++ A ++ + | | + | | + | | + 3.5 ++ ++ + | | + | | + | | + 3 ++ A ++ + | | + | | + | | + | | + 2.5 ++ ++ + | | + | | + | | + 2 ++ A ++ + | | + | | + | | + | | + 1.5 ++ ++ + | | + | | + + + + + + + 1 ++---+---+----+---+----+---+----+---A----+---+----+---+----+---+----+---+----+---+----+--++ + 05:00 05:05 05:10 05:15 05:20 + +EOF + +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}'}, + options => ['--domain', '--timefmt', '%d %b %Y %H:%M:%S', + '--monotonic'], + refplot => <<'EOF' ); + + + 10 ++---------+-----------+----------+----------+----------+-----------+----------+---------+A + + + + + + + + + + + | | + | | + 9.5 ++ ++ + | | + | | + | | + | | + 9 ++ A ++ + | | + | | + | | + 8.5 ++ ++ + | | + | | + | | + 8 ++ A ++ + | | + | | + | | + | | + 7.5 ++ ++ + | | + | | + | | + 7 ++ A ++ + | | + | | + | | + | | + 6.5 ++ ++ + | | + | | + + + + + + + + + + + 6 A+---------+-----------+----------+----------+----------+-----------+----------+---------++ + 05:07 05:07 05:08 05:08 05:09 05:09 05:10 05:10 05:11 + +EOF + + + + +note( "Starting to run streaming tests. These will take several seconds each" ); + +# replotting every 1.0 seconds. Data comes in every 1.1 seconds. Two data +# 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 +tryplot( testname => 'basic streaming test', + cmd => q{seq 500 | awk 'BEGIN{ print 0; } {print (NR==3)? "exit" : $0; fflush(); system("sleep 1.2");}'}, + options => [qw(--lines --points --stream)], + refplot => <<'EOF' ); + + + 1 ++----------------+-----------------+-----------------+-----------------+----------------*A + + + + + + ** + + | *** | + | *** | + | ** | + | *** | + | ** | + 0.8 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + | ** | + 0.6 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + | ** | + 0.4 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + | ** | + 0.2 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + + ** + + + + + + 0 A*----------------+-----------------+-----------------+-----------------+----------------++ + 1 1.2 1.4 1.6 1.8 2 + + + + 2 ++---------------------+---------------------+----------------------+--------------------*A + + + + + ** + + | *** | + | *** | + | ** | + | *** | + | *** | + | ** | + | *** | + 1.5 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + | *** | + | ** | + 1 ++ *A* ++ + | ** | + | *** | + | ** | + | *** | + | ** | + | *** | + | ** | + | *** | + 0.5 ++ ** ++ + | *** | + | ** | + | *** | + | ** | + | *** | + | ** | + | *** | + + ** + + + + + 0 A*---------------------+---------------------+----------------------+--------------------++ + 1 1.5 2 2.5 3 + +EOF + +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");}'}, + options => [qw(--lines --points --stream 0.4)], + refplot => <<'EOF' ); + + + 1 ++----------------+-----------------+-----------------+-----------------+----------------*A + + + + + + ** + + | *** | + | *** | + | ** | + | *** | + | ** | + 0.8 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + | ** | + 0.6 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + | ** | + 0.4 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + | ** | + 0.2 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + + ** + + + + + + 0 A*----------------+-----------------+-----------------+-----------------+----------------++ + 1 1.2 1.4 1.6 1.8 2 + + + + 2 ++---------------------+---------------------+----------------------+--------------------*A + + + + + ** + + | *** | + | *** | + | ** | + | *** | + | *** | + | ** | + | *** | + 1.5 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + | *** | + | ** | + 1 ++ *A* ++ + | ** | + | *** | + | ** | + | *** | + | ** | + | *** | + | ** | + | *** | + 0.5 ++ ** ++ + | *** | + | ** | + | *** | + | ** | + | *** | + | ** | + | *** | + + ** + + + + + 0 A*---------------------+---------------------+----------------------+--------------------++ + 1 1.5 2 2.5 3 + +EOF + + +tryplot( testname => 'streaming with --xlen', + cmd => q{seq 500 | awk 'BEGIN{ print 0; } {print (NR==3)? "exit" : $0; fflush(); system("sleep 0.6");}'}, + options => [qw(--lines --points --stream 0.4 --xlen 1.1)], + refplot => <<'EOF' ); + + + 1 ++------+----------------+---------------+---------------+----------------+--------------*A + | + + + + + ** + + | ** | + | *** | + | ** | + | ** | + | *** | + 0.8 ++ ** ++ + | ** | + | *** | + | ** | + | ** | + | *** | + | ** | + 0.6 ++ ** ++ + | *** | + | ** | + | *** | + | ** | + | ** | + | *** | + 0.4 ++ ** ++ + | ** | + | *** | + | ** | + | ** | + | *** | + | ** | + 0.2 ++ ** ++ + | *** | + | ** | + | ** | + | *** | + | ** | + | + ** + + + + + + 0 ++------A*---------------+---------------+---------------+----------------+--------------++ + 1 1.2 1.4 1.6 1.8 2 + + + + 2 ++------+----------------+---------------+---------------+----------------+--------------*A + | + + + + + ** + + | ** | + | *** | + | ** | + | ** | + | *** | + 1.8 ++ ** ++ + | ** | + | *** | + | ** | + | ** | + | *** | + | ** | + 1.6 ++ ** ++ + | *** | + | ** | + | *** | + | ** | + | ** | + | *** | + 1.4 ++ ** ++ + | ** | + | *** | + | ** | + | ** | + | *** | + | ** | + 1.2 ++ ** ++ + | *** | + | ** | + | ** | + | *** | + | ** | + | + ** + + + + + + 1 ++------A*---------------+---------------+---------------+----------------+--------------++ + 2 2.2 2.4 2.6 2.8 3 + +EOF + +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");}'}, + options => [qw(--lines --points --stream 0.4 --domain --monotonic)], + refplot => <<'EOF' ); + + + 1 ++----------------+-----------------+-----------------+-----------------+----------------*A + + + + + + ** + + | *** | + | *** | + | ** | + | *** | + | ** | + | *** | + | ** | + 0.5 ++ *** ++ + | *** | + | ** | + | *** | + | ** | + | *** | + | ** | + | *** | + 0 ++ *** ++ + | ** | + | *** | + | ** | + | *** | + | ** | + | *** | + | *** | + | ** | + -0.5 ++ *** ++ + | ** | + | *** | + | ** | + | *** | + | *** | + | ** | + | *** | + + ** + + + + + + -1 A*----------------+-----------------+-----------------+-----------------+----------------++ + -1 -0.8 -0.6 -0.4 -0.2 0 + + + + 2 ++---------------------+---------------------+----------------------+--------------------*A + + + + + **** + + | **** | + | **** | + | *** | + | **** | + 1.5 ++ **** ++ + | **** | + | *** | + | **** | + | **** | + | **** | + 1 ++ A* ++ + | ** | + | ** | + | ** | + | ** | + 0.5 ++ ** ++ + | ** | + | ** | + | ** | + | ** | + | ** | + 0 ++ ** ++ + | ** | + | ** | + | ** | + | ** | + | ** | + -0.5 ++ ** ++ + | ** | + | ** | + | ** | + | ** | + +** + + + + + -1 A+---------------------+---------------------+----------------------+--------------------++ + -1 -0.5 0 0.5 1 + + + + 3 ++-------------+--------------+--------------+--------------+--------------+-------------*A + + + + + + + **** + + | *** | + | *** | + 2.5 ++ **** ++ + | *** | + | *** | + | **** | + | *** | + 2 ++ *A* ++ + | **** | + | **** | + | **** | + 1.5 ++ *** ++ + | **** | + | **** | + | **** | + 1 ++ A* ++ + | ** | + | ** | + | * | + | ** | + 0.5 ++ ** ++ + | * | + | ** | + | ** | + 0 ++ * ++ + | ** | + | ** | + | * | + | ** | + -0.5 ++ ** ++ + | * | + | ** | + +** + + + + + + + -1 A+-------------+--------------+--------------+--------------+--------------+-------------++ + -1 -0.5 0 0.5 1 1.5 2 + + + + 4 ++----------+----------+-----------+----------+-----------+----------+-----------+---------*A + + + + + + + + + *** + + | **** | + | *** | + | *** | + | **** | + | *** | + 3 ++ *A* ++ + | *** | + | **** | + | *** | + | *** | + | **** | + | *** | + 2 ++ *A* ++ + | *** | + | **** | + | *** | + | *** | + | **** | + | *** | + 1 ++ A* ++ + | ** | + | ** | + | * | + | ** | + | ** | + | * | + 0 ++ ** ++ + | * | + | ** | + | ** | + | * | + | ** | + +** + + + + + + + + + -1 A+----------+----------+-----------+----------+-----------+----------+-----------+---------++ + -1 -0.5 0 0.5 1 1.5 2 2.5 3 + + + + 5 ++----------------+------------------+-----------------+------------------+----------------*A + + + + + + *** + + | *** | + | *** | + | *** | + | *** | + 4 ++ *A* ++ + | *** | + | *** | + | **** | + | *** | + | *** | + 3 ++ *A* ++ + | **** | + | **** | + | *** | + | **** | + 2 ++ *A* ++ + | *** | + | *** | + | **** | + | *** | + | *** | + 1 ++ A* ++ + | ** | + | * | + | ** | + | * | + | ** | + 0 ++ * ++ + | ** | + | * | + | ** | + | * | + +** + + + + + + -1 A+----------------+------------------+-----------------+------------------+----------------++ + -1 0 1 2 3 4 + + + + 6 ++----------------+------------------+-----------------+------------------+----------------*A + + + + + + ** + + | *** | + | *** | + | ** | + 5 ++ *** ++ + | *** | + | ** | + | *** | + | ** | + 4 ++ *** ++ + | *** | + | ** | + | *** | + | *** | + 3 ++ ** ++ + | *** | + | *** | + | ** | + | *** | + 2 ++ ** ++ + | *** | + | *** | + | ** | + | *** | + 1 ++ *** ++ + | ** | + | *** | + | ** | + | *** | + 0 ++ *** ++ + | ** | + | *** | + | *** | + + ** + + + + + + -1 A*----------------+------------------+-----------------+------------------+----------------++ + -1 -0.8 -0.6 -0.4 -0.2 0 + + + + 7 ++---------------------+----------------------+----------------------+-----------------*****A + + + + + ************ + + | *********** | + | ************ | + 6 ++ A***** ++ + | ** | + | * | + | ** | + | * | + 5 ++ ** ++ + | * | + | ** | + | * | + 4 ++ ** ++ + | * | + | ** | + | * | + 3 ++ ** ++ + | * | + | ** | + | * | + | * | + 2 ++ ** ++ + | * | + | ** | + | * | + 1 ++ ** ++ + | * | + | ** | + | * | + | ** | + 0 ++ * ++ + | ** | + | * | + +** + + + + + -1 A+---------------------+----------------------+----------------------+---------------------++ + -1 -0.5 0 0.5 1 + + + + 8 ++-------------+---------------+--------------+--------------+---------------+-----------***A + + + + + + + ******** + + | ******** | + | ******** | + 7 ++ ***A*** ++ + | ******** | + | ******* | + | ******** | + 6 ++ A*** ++ + | * | + | * | + | ** | + 5 ++ * ++ + | * | + | * | + | * | + 4 ++ * ++ + | * | + | ** | + 3 ++ * ++ + | * | + | * | + | * | + 2 ++ * ++ + | * | + | ** | + | * | + 1 ++ * ++ + | * | + | * | + | * | + 0 ++ * ++ + | ** | + | * | + +* + + + + + + + -1 A+-------------+---------------+--------------+--------------+---------------+-------------++ + -1 -0.5 0 0.5 1 1.5 2 + + + + 10 ++---------+-----------+----------+-----------+----------+----------+-----------+---------++ + + + + + + + + + + + | | + | ***A + | ******** | + | ******** | + 8 ++ ***A*** ++ + | ******** | + | ******* | + | ***A*** | + | ******** | + | ******** | + 6 ++ A*** ++ + | * | + | * | + | ** | + | * | + 4 ++ * ++ + | * | + | * | + | * | + | * | + | ** | + 2 ++ * ++ + | * | + | * | + | * | + | * | + | * | + 0 ++ ** ++ + | * | + |* | + A | + | | + + + + + + + + + + + -2 ++---------+-----------+----------+-----------+----------+----------+-----------+---------++ + -1 -0.5 0 0.5 1 1.5 2 2.5 3 + + + + 10 ++----------------+-----------------+------------------+-----------------+--------------***A + + + + + + ****** + + | ****** | + | ***A** | + | ****** | + | ****** | + 8 ++ ***A** ++ + | ****** | + | ****** | + | ***A*** | + | ****** | + | ****** | + 6 ++ A** ++ + | * | + | * | + | * | + | * | + 4 ++ * ++ + | * | + | * | + | * | + | * | + | * | + 2 ++ * ++ + | * | + | * | + | * | + | * | + | * | + 0 ++ * ++ + | * | + |* | + A | + | | + + + + + + + + -2 ++----------------+-----------------+------------------+-----------------+----------------++ + -1 0 1 2 3 4 + +EOF + +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")}'}, + options => ['--points', '--lines', + '--domain', '--timefmt', '%d %b %Y %H:%M:%S', + qw(--stream 0.4 --xlen 3)], + refplot => <<'EOF' ); + + + 1 ++-------------+---------------+--------------+--------------+---------------+-------------+A + + + + + + + **+ + | ** | + | ** | + | * | + | ** | + | ** | + 0 ++ ** ++ + | * | + | ** | + | ** | + | ** | + | * | + | ** | + -1 ++ ** ++ + | ** | + | * | + | ** | + | ** | + | * | + | ** | + -2 ++ ** ++ + | ** | + | * | + | ** | + | ** | + | ** | + | * | + -3 ++ ** ++ + | ** | + | ** | + | * | + | ** | + | ** | + + + +** + + + + + -4 ++-------------+---------------A--------------+--------------+---------------+-------------++ + 05:05 05:05 05:06 05:06 05:07 05:07 05:08 + + + + 2 ++-------------+---------------+--------------+--------------+---------------+------------**A + + + + + + + ***** + + | ***** | + | ****** | + | ***** | + | ***** | + 1 ++ *A** ++ + | ** | + | ** | + | ** | + | ** | + | ** | + 0 ++ ** ++ + | ** | + | ** | + | ** | + | *** | + -1 ++ ** ++ + | ** | + | ** | + | ** | + | ** | + | ** | + -2 ++ ** ++ + | ** | + | *** | + | ** | + | ** | + | ** | + -3 ++ ** ++ + | ** | + | ** | + | ** | + | ** | + + ** + + + + + + + -4 A*-------------+---------------+--------------+--------------+---------------+-------------++ + 05:06 05:06 05:07 05:07 05:08 05:08 05:09 + +EOF + +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")}'}, + options => ['--points', '--lines', + '--domain', '--timefmt', '%d %b %Y %H:%M:%S', + qw(--stream 0.4 --monotonic)], + refplot => <<'EOF' ); + + + 1 ++----------------+------------------+-----------------+------------------+----------------*A + + + + + + ** + + | *** | + | *** | + | ** | + | *** | + | *** | + 0 ++ ** ++ + | *** | + | ** | + | *** | + | *** | + | ** | + | *** | + -1 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + | ** | + -2 ++ *** ++ + | *** | + | ** | + | *** | + | *** | + | ** | + | *** | + -3 ++ ** ++ + | *** | + | *** | + | ** | + | *** | + | *** | + + ** + + + + + + -4 A*----------------+------------------+-----------------+------------------+----------------++ + 05:06 05:06 05:06 05:06 05:06 05:06 + + + + 2 ++---------------------+----------------------+----------------------+-------------------***A + + + + + ******** + + | ******** | + | ******* | + | ******** | + | ******** | + 1 ++ A*** ++ + | ** | + | * | + | ** | + | ** | + | * | + 0 ++ ** ++ + | * | + | ** | + | ** | + | * | + -1 ++ ** ++ + | * | + | ** | + | ** | + | * | + | ** | + -2 ++ * ++ + | ** | + | * | + | ** | + | ** | + | * | + -3 ++ ** ++ + | * | + | ** | + | ** | + | * | + +** + + + + + -4 A+---------------------+----------------------+----------------------+---------------------++ + 05:06 05:06 05:07 05:07 05:08 + + + + 3 ++-------------+---------------+--------------+--------------+---------------+-----------***A + + + + + + + ****** + + | ****** | + | ****** | + | ****** | + 2 ++ ***A*** ++ + | ****** | + | ****** | + | ****** | + | ****** | + 1 ++ A** ++ + | * | + | ** | + | * | + | * | + 0 ++ * ++ + | ** | + | * | + | * | + | * | + -1 ++ ** ++ + | * | + | * | + | * | + | * | + -2 ++ ** ++ + | * | + | * | + | * | + | ** | + -3 ++ * ++ + | * | + | * | + | ** | + +* + + + + + + + -4 A+-------------+---------------+--------------+--------------+---------------+-------------++ + 05:06 05:06 05:07 05:07 05:08 05:08 05:09 + + + + 4 ++----------+----------+-----------+----------+-----------+----------+-----------+--------**A + + + + + + + + + ****** + + | ****** | + | ****** | + 3 ++ **A** ++ + | **** | + | ***** | + | ***** | + | **** | + 2 ++ **A** ++ + | ****** | + | ****** | + | ****** | + 1 ++ A** ++ + | * | + | * | + | * | + 0 ++ * ++ + | * | + | * | + | * | + | * | + -1 ++ * ++ + | * | + | ** | + | * | + -2 ++ * ++ + | * | + | * | + | * | + | * | + -3 ++ * ++ + | * | + | * | + +* + + + + + + + + + -4 A+----------+----------+-----------+----------+-----------+----------+-----------+---------++ + 05:06 05:06 05:07 05:07 05:08 05:08 05:09 05:09 05:10 + + + + 5 ++----------------+------------------+-----------------+------------------+---------------**A + + + + + + **** + + | ***** | + | **** | + 4 ++ **A** ++ + | ***** | + | **** | + | ***** | + 3 ++ **A** ++ + | **** | + | ***** | + | **** | + 2 ++ **A** ++ + | ***** | + | **** | + | ***** | + 1 ++ A** ++ + | * | + | * | + 0 ++ * ++ + | * | + | * | + | * | + -1 ++ * ++ + | * | + | * | + | * | + -2 ++ * ++ + | * | + | * | + | * | + -3 ++ * ++ + | * | + | * | + +* + + + + + + -4 A+----------------+------------------+-----------------+------------------+----------------++ + 05:06 05:07 05:08 05:09 05:10 05:11 + + + + 6 ++----------------+------------------+-----------------+------------------+----------------*A + + + + + + ** + + | *** | + | *** | + | ** | + | *** | + | *** | + 4 ++ ** ++ + | *** | + | ** | + | *** | + | *** | + | ** | + | *** | + 2 ++ *** ++ + | ** | + | *** | + | *** | + | ** | + | *** | + | ** | + 0 ++ *** ++ + | *** | + | ** | + | *** | + | *** | + | ** | + | *** | + -2 ++ ** ++ + | *** | + | *** | + | ** | + | *** | + | *** | + + ** + + + + + + -4 A*----------------+------------------+-----------------+------------------+----------------++ + 05:06 05:06 05:06 05:06 05:06 05:06 + + + + 8 ++---------------------+----------------------+----------------------+---------------------++ + + + + + + + | | + | *******A + | **************** | + | *************** | + 6 ++ A******* ++ + | ** | + | * | + | ** | + | ** | + | * | + 4 ++ ** ++ + | * | + | ** | + | ** | + | * | + 2 ++ ** ++ + | * | + | ** | + | ** | + | * | + | ** | + 0 ++ * ++ + | ** | + | * | + | ** | + | ** | + | * | + -2 ++ ** ++ + | * | + | ** | + | ** | + | * | + +** + + + + + -4 A+---------------------+----------------------+----------------------+---------------------++ + 05:06 05:06 05:07 05:07 05:08 + + + + 8 ++-------------+---------------+--------------+--------------+---------------+---------*****A + + + + + + ********** + + | ********** | + | *****A***** | + | ********** | + | ********** | + 6 ++ A**** ++ + | * | + | * | + | * | + | * | + | * | + 4 ++ * ++ + | ** | + | * | + | * | + | * | + 2 ++ * ++ + | * | + | * | + | * | + | * | + | * | + 0 ++ * ++ + | * | + | * | + | * | + | * | + | ** | + -2 ++ * ++ + | * | + | * | + | * | + | * | + +* + + + + + + + -4 A+-------------+---------------+--------------+--------------+---------------+-------------++ + 05:06 05:06 05:07 05:07 05:08 05:08 05:09 + + + + 10 ++---------+-----------+----------+-----------+----------+----------+-----------+---------++ + + + + + + + + + + + | ***A + | ******** | + | ******** | + 8 ++ *****A*** ++ + | *********** | + | ***A***** | + | ******** | + | ******** | + 6 ++ A*** ++ + | * | + | * | + | * | + | * | + 4 ++ * ++ + | * | + | * | + | * | + | * | + 2 ++ * ++ + | * | + | * | + | * | + | * | + 0 ++ * ++ + | * | + | * | + | * | + | * | + -2 ++ * ++ + | * | + | * | + | * | + +* + + + + + + + + + -4 A+---------+-----------+----------+-----------+----------+----------+-----------+---------++ + 05:06 05:06 05:07 05:07 05:08 05:08 05:09 05:09 05:10 + + + + 10 ++----------------+-----------------+------------------+-----------------+-------------****A + + + + + + ********* + + | ***A**** | + | ****** | + | ****** | + 8 ++ ****A** ++ + | ********** | + | ***A**** | + | ****** | + | ****** | + 6 ++ A** ++ + | * | + | * | + | * | + | * | + 4 ++ * ++ + | * | + | * | + | * | + | * | + 2 ++ * ++ + | * | + | * | + | * | + | * | + 0 ++ * ++ + | * | + | * | + | * | + | * | + -2 ++ * ++ + | * | + | * | + |* | + +* + + + + + + -4 A+----------------+-----------------+------------------+-----------------+----------------++ + 05:06 05:07 05:08 05:09 05:10 05:11 + +EOF + + + + +sub tryplot +{ + my %args = @_; + + my @options = ('--exit', + '--extracmds', 'unset grid', + '--terminal', 'dumb 100,40'); + unshift @options, @{$args{options}}; + + my $feedgnuplot = dirname($0) . "/../bin/feedgnuplot"; + my $out = ''; + my $err = ''; + open IN, '-|', $args{cmd} or die "Couldn't open pipe to $args{cmd}"; + run [$feedgnuplot, @options], + \*IN, \$out, \$err; + + note( "Running test '$args{testname}'. Running: $args{cmd} | $feedgnuplot " . + shell_quote(@options)); + is($err, '', "$args{testname} stderr" ); + is($out, $args{refplot}, "$args{testname} stdout"); +}