diff --git a/Changes b/Changes index 8ec9e2f..012010d 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,12 @@ +feedgnuplot (1.40) + + * If the options couldn't be parsed I don't dump the whole manpage + * --style and --rangesize can now take a comma-separated list of IDs + * 'any' is from List::MoreUtils, not List::Util + * the sleep-forever delay at end is now > 1000 days + + -- Dima Kogan Fri, 25 Nov 2016 14:45:06 -0800 + feedgnuplot (1.39) * by default, histograms are plotted in expected ways diff --git a/Makefile.PL b/Makefile.PL index dd3ed3f..a02c839 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -64,6 +64,7 @@ WriteMakefile PL_FILES => {}, EXE_FILES => [ 'bin/feedgnuplot' ], BUILD_REQUIRES => { 'String::ShellQuote' => 0, + 'List::MoreUtils' => 0, 'IPC::Run' => 0}, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'feedgnuplot-*' }, diff --git a/bin/feedgnuplot b/bin/feedgnuplot index d04626d..ce3965a 100755 --- a/bin/feedgnuplot +++ b/bin/feedgnuplot @@ -8,13 +8,14 @@ use Getopt::Long; use Time::HiRes qw( usleep gettimeofday tv_interval ); use IO::Handle; use IO::Select; -use List::Util qw( first any ); +use List::Util qw( first ); +use List::MoreUtils 'any'; use Scalar::Util qw( looks_like_number ); use Text::ParseWords; # for shellwords use Pod::Usage; use Time::Piece; -my $VERSION = 1.39; +my $VERSION = 1.40; my %options; interpretCommandline(); @@ -108,9 +109,7 @@ sub interpretCommandline 'terminal=s', 'rangesize=s{2}', 'rangesizeall=i', 'extraValuesPerPoint=i', 'help', 'dump', 'exit', 'version', - 'geometry=s') or pod2usage( -exitval => 1, - -verbose => 1, # synopsis and args - -output => \*STDERR ); + 'geometry=s') or exit 1; # handle various cmdline-option errors @@ -127,13 +126,6 @@ sub interpretCommandline exit 0; } - # expand options that are given as comma-separated lists - for my $listkey (qw(histogram y2)) - { - @{$options{$listkey}} = map split('\s*,\s*', $_), @{$options{$listkey}} - if defined $options{$listkey}; - } - # --style and --curvestyle are synonyms, as are --styleall and # --curvestyleall, so fill that in if( $options{styleall} ) @@ -157,6 +149,33 @@ sub interpretCommandline delete $options{with}; } + + # expand options that are given as comma-separated lists + for my $listkey (qw(histogram y2)) + { + @{$options{$listkey}} = map split('\s*,\s*', $_), @{$options{$listkey}} + if defined $options{$listkey}; + } + for my $listkey (qw(curvestyle rangesize)) + { + next unless defined $options{$listkey}; + my @in = @{$options{$listkey}}; + my $N = @in / 2; + my @out; + for my $i (0..$N-1) + { + my $key = $in[2*$i]; + my $value = $in[2*$i + 1]; + for my $key_new (split('\s*,\s*', $key)) + { + push @out, $key_new, $value; + } + } + + @{$options{$listkey}} = @out; + } + + # If we're plotting histograms, then set the default histogram options for # each histogram curve # @@ -786,7 +805,7 @@ sub mainThread # we persist gnuplot, so we shouldn't need this sleep. However, once # gnuplot exits, but the persistent window sticks around, you can no # longer interactively zoom the plot. So we still sleep - sleep(100000) unless $options{dump} || $options{exit}; + sleep(100000000) unless $options{dump} || $options{exit}; } sub pruneOldData @@ -1279,7 +1298,9 @@ This command causes feedgnuplot to exit. The script is able to produce hardcopy output with C<--hardcopy outputfile>. The output type can be inferred from the filename, if B<.ps>, B<.eps>, B<.pdf>, B<.svg> or B<.png> is requested. If any other file type is requested, -C<--terminal> I be passed in to tell gnuplot how to make the plot. +C<--terminal> I be passed in to tell gnuplot how to make the plot. If +C<--terminal> is passed in, then the C<--hardcopy> argument only provides the +output filename. =head2 Self-plotting data files @@ -1548,9 +1569,10 @@ report 0 or 1. 'cumulative' is the integral of the 'frequency' histogram. C<--style curveID style> Additional styles per curve. With C<--dataid>, curveID is the ID. Otherwise, -it's the index of the curve, starting at 0. Use this option multiple times for -multiple curves. C<--styleall> does I apply to curves that have a -C<--style> +it's the index of the curve, starting at 0. curveID can be a comma-separated +list of IDs to which the given style should apply. Use this option multiple +times for multiple curves. C<--styleall> does I apply to curves that have a +C<--style>. =item @@ -1653,16 +1675,17 @@ For 3D plots, set square aspect ratio for ONLY the x,y axes C<--hardcopy xxx> If not streaming, output to a file specified here. Format inferred from -filename, unless specified by C<--terminal> +filename, unless specified by C<--terminal>. If C<--terminal> is given, +C<--hardcopy> sets I the output filename. =item C<--terminal xxx> String passed to 'set terminal'. No attempts are made to validate this. -C<--hardcopy> sets this to some sensible defaults if --hardcopy is given .png, -.pdf, .ps, .eps or .svg. If any other file type is desired, use both -C<--hardcopy> and C<--terminal> +C<--hardcopy> sets this to some sensible defaults if C<--hardcopy> is set to a +filename ending in C<.png>, C<.pdf>, C<.ps>, C<.eps> or C<.svg>. If any other +file type is desired, use both C<--hardcopy> and C<--terminal> =item @@ -1695,6 +1718,10 @@ 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. +With C<--dataid>, curveID is the ID. Otherwise, it's the index of the curve, +starting at 0. curveID can be a comma-separated list of IDs to which the given +rangesize should apply. + =item C<--rangesizeall xxx> @@ -1856,6 +1883,19 @@ in a Thinkpad. --binwidth 10 --ymin 0 --xlabel 'File size (MB)' --ylabel Frequency +=head2 Plotting points on top of an existing image + +This can be done by using C<--equation> to pass arbitrary plot input to gnuplot: + + $ < features_xy.data + feedgnuplot --points --domain + --equation '"image.png" binary filetype=png flipy with rgbimage' + +Here an existing image is given to gnuplot verbatim, and data to plot on top of +it is interpreted by feedgnuplot as usual. C is useful here because +usually the y axis points up, but when looking at images, this is usually +reversed: the origin is the top-left pixel. + =head1 ACKNOWLEDGEMENT This program is originally based on the driveGnuPlots.pl script from