mirror of
https://github.com/dkogan/feedgnuplot.git
synced 2025-09-18 10:28:12 +08:00
Compare commits
7 Commits
debian/1.4
...
v1.43
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7d7511e62e | ||
![]() |
1744aeb6d2 | ||
![]() |
53f6cdae5b | ||
![]() |
ed9512924d | ||
![]() |
2ee401fcb4 | ||
![]() |
7c1f02ec7f | ||
![]() |
5740e55a6f |
13
Changes
13
Changes
@@ -1,3 +1,16 @@
|
||||
feedgnuplot (1.43)
|
||||
|
||||
* Added --image
|
||||
|
||||
-- Dima Kogan <dima@secretsauce.net> Mon, 19 Jun 2017 13:12:38 -0700
|
||||
|
||||
feedgnuplot (1.42)
|
||||
|
||||
* Data can now come from STDIN or files on the cmdline.
|
||||
This fixes a regression. Self-plotting data files work again
|
||||
|
||||
-- Dima Kogan <dima@secretsauce.net> Fri, 31 Mar 2017 15:38:47 -0700
|
||||
|
||||
feedgnuplot (1.41)
|
||||
|
||||
* Histograms: --xlen can coexist with --xmin/--xmax
|
||||
|
150
bin/feedgnuplot
150
bin/feedgnuplot
@@ -15,7 +15,7 @@ use Text::ParseWords; # for shellwords
|
||||
use Pod::Usage;
|
||||
use Time::Piece;
|
||||
|
||||
my $VERSION = 1.41;
|
||||
my $VERSION = 1.43;
|
||||
|
||||
my %options;
|
||||
interpretCommandline();
|
||||
@@ -41,17 +41,10 @@ my $last_replot_time = [gettimeofday];
|
||||
|
||||
# whether the previous replot was timer based
|
||||
my $last_replot_is_from_timer = 1;
|
||||
|
||||
|
||||
my $prev_timed_replot_time = [gettimeofday];
|
||||
my $this_replot_is_from_timer;
|
||||
my $stdin = IO::Handle->new();
|
||||
die "Couldn't open STDIN" unless $stdin->fdopen(fileno(STDIN),"r");
|
||||
my $selector = IO::Select->new( $stdin );
|
||||
|
||||
|
||||
|
||||
mainThread();
|
||||
|
||||
|
||||
|
||||
@@ -116,13 +109,13 @@ sub interpretCommandline
|
||||
'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',
|
||||
'equation=s@',
|
||||
'image=s',
|
||||
'histogram=s@', 'binwidth=f', 'histstyle=s',
|
||||
'terminal=s',
|
||||
'rangesize=s{2}', 'rangesizeall=i', 'extraValuesPerPoint=i',
|
||||
'help', 'dump', 'exit', 'version',
|
||||
'geometry=s') or exit 1;
|
||||
|
||||
|
||||
# handle various cmdline-option errors
|
||||
if ( $options{help} )
|
||||
{
|
||||
@@ -427,6 +420,27 @@ sub interpretCommandline
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# deal with --image. I just fill in --equation, and reverse the y extents if
|
||||
# none are explicitly given
|
||||
if( defined $options{image} )
|
||||
{
|
||||
# images generally have the origin at the top-left instead of the
|
||||
# bottom-left, so given nothing else, I flip the y axis
|
||||
if( !defined $options{ymin} && !defined $options{ymax} &&
|
||||
! any { /^ *yrange\b/ } @{$options{set}} )
|
||||
{
|
||||
push @{$options{set}}, "yrange [:] reverse";
|
||||
}
|
||||
|
||||
if ( ! -r $options{image} )
|
||||
{
|
||||
die "Couldn't read image '$options{image}'";
|
||||
}
|
||||
|
||||
push @{$options{equation}}, qq{"$options{image}" binary filetype=auto flipy with rgbimage};
|
||||
delete $options{image};
|
||||
}
|
||||
}
|
||||
|
||||
sub getGnuplotVersion
|
||||
@@ -479,16 +493,66 @@ sub makeDomainNumeric
|
||||
}
|
||||
|
||||
|
||||
my $prev_timed_replot_time = [gettimeofday];
|
||||
my $pipe_in;
|
||||
my $selector;
|
||||
my $line_number = 0;
|
||||
my $is_stdin = !@ARGV; # read stdin only if no data files given on the cmdline
|
||||
sub openNextFile
|
||||
{
|
||||
my $fd;
|
||||
if($is_stdin)
|
||||
{
|
||||
$fd = IO::Handle->new();
|
||||
$fd->fdopen(fileno(STDIN), "r") or die "Couldn't open STDIN";
|
||||
}
|
||||
else
|
||||
{
|
||||
my $filename = shift @ARGV;
|
||||
$fd = IO::File->new($filename, "r") or die "Couldn't open file '$filename'";
|
||||
}
|
||||
|
||||
my $selector = IO::Select->new( $fd );
|
||||
return ($fd, $selector);
|
||||
}
|
||||
sub getNextLine
|
||||
{
|
||||
sub getline_internal
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
my $line = $pipe_in->getline();
|
||||
if( !$is_stdin && !defined $line && $pipe_in->eof() && @ARGV)
|
||||
{
|
||||
# I got to the end of one file, so open the next one (which I'm
|
||||
# sure exists)
|
||||
($pipe_in, $selector) = openNextFile();
|
||||
next;
|
||||
}
|
||||
return $line;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if( !defined $pipe_in )
|
||||
{
|
||||
($pipe_in, $selector) = openNextFile();
|
||||
}
|
||||
|
||||
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);
|
||||
if (! $options{stream} || $options{stream} < 0)
|
||||
{
|
||||
$line_number++;
|
||||
return getline_internal();
|
||||
}
|
||||
|
||||
|
||||
my $now = [gettimeofday];
|
||||
@@ -503,7 +567,8 @@ sub getNextLine
|
||||
|
||||
if ($selector->can_read($time_remaining))
|
||||
{
|
||||
return $stdin->getline();
|
||||
$line_number++;
|
||||
return getline_internal();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -773,7 +838,7 @@ sub mainThread
|
||||
}
|
||||
else
|
||||
{
|
||||
$domain[0] = $.;
|
||||
$domain[0] = $line_number;
|
||||
$domain0_numeric = makeDomainNumeric( $domain[0] );
|
||||
}
|
||||
|
||||
@@ -1082,6 +1147,9 @@ sub pushPoint
|
||||
}
|
||||
|
||||
|
||||
mainThread();
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
feedgnuplot - General purpose pipe-oriented plotting tool
|
||||
@@ -1683,6 +1751,17 @@ times.
|
||||
|
||||
=item
|
||||
|
||||
C<--image filename>
|
||||
|
||||
Overlays the data on top of a raster image given in C<filename>. This is passed
|
||||
through to gnuplot via C<--equation>, and is not interpreted by C<feedgnuplot>
|
||||
other than checking for existence. Usually images have their origin at the
|
||||
top-left corner, while plots have it in the bottom-left corner instead. Thus if
|
||||
the y-axis extents are not specified (C<--ymin>, C<--ymax>, C<--set 'yrange
|
||||
...'>) this option will also flip around the y axis to make the image appear
|
||||
properly. Since this option is just a passthrough to gnuplot, finer control can
|
||||
be achieved by passing in C<--equation> and C<--set yrange ...> directly.
|
||||
|
||||
C<--equation xxx>
|
||||
|
||||
Gnuplot can plot both data and symbolic equations. C<feedgnuplot> generally
|
||||
@@ -1801,16 +1880,15 @@ is possible to send the output produced this way to gnuplot directly.
|
||||
|
||||
C<--exit>
|
||||
|
||||
This controls the details of what happens when the input data is exhausted, or
|
||||
when some part of the C<feedgnuplot> pipeline is killed. This option does
|
||||
different things depending on whether C<--stream> is active, so read this
|
||||
closely.
|
||||
This controls what happens when the input data is exhausted, or when some part
|
||||
of the C<feedgnuplot> pipeline is killed. This option does different things
|
||||
depending on whether C<--stream> is active, so read this 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:
|
||||
that such decapitated windows aren't interactive). There are 3 possible states
|
||||
of the polotting pipeline:
|
||||
|
||||
=over
|
||||
|
||||
@@ -1825,35 +1903,35 @@ prompt available
|
||||
|
||||
=back
|
||||
|
||||
The C<--exit> option controls the details of this behavior. The possibilities
|
||||
are:
|
||||
The possibilities are:
|
||||
|
||||
=over
|
||||
|
||||
=item No C<--stream>, input pipe is exhausted (all data read in)
|
||||
=item No C<--stream>, all data read in
|
||||
|
||||
=over
|
||||
|
||||
=item default; no C<--exit>
|
||||
=item no C<--exit> (default)
|
||||
|
||||
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.
|
||||
Without C<--stream> the goal is to show a plot, so a Dead state would not be
|
||||
useful.
|
||||
|
||||
=back
|
||||
|
||||
=item C<--stream>, input pipe is exhausted (all data read in) or the
|
||||
C<feedgnuplot> process terminated
|
||||
=item C<--stream>, all data read in or the C<feedgnuplot> process terminated
|
||||
|
||||
=over
|
||||
|
||||
=item default; no C<--exit>
|
||||
=item no C<--exit> (default)
|
||||
|
||||
Alive. Need to Ctrl-C to get back into the shell
|
||||
Alive. Need to Ctrl-C to get back into the shell. This means that when making
|
||||
live plots, the first Ctrl-C kills the data feeding process, but leaves the
|
||||
final plot up for inspection. A second Ctrl-C kills feedgnuplot as well.
|
||||
|
||||
=item C<--exit>
|
||||
|
||||
@@ -1948,11 +2026,21 @@ in a Thinkpad.
|
||||
|
||||
=head2 Plotting points on top of an existing image
|
||||
|
||||
This can be done by using C<--equation> to pass arbitrary plot input to gnuplot:
|
||||
This can be done with C<--image>:
|
||||
|
||||
$ < features_xy.data
|
||||
feedgnuplot --points --domain --image "image.png"
|
||||
|
||||
or with C<--equation>:
|
||||
|
||||
$ < features_xy.data
|
||||
feedgnuplot --points --domain
|
||||
--equation '"image.png" binary filetype=png flipy with rgbimage'
|
||||
--equation '"image.png" binary filetype=auto flipy with rgbimage'
|
||||
--set 'yrange [:] reverse'
|
||||
|
||||
The C<--image> invocation is a convenience wrapper for the C<--equation>
|
||||
version. Finer control is available with C<--equation>.
|
||||
|
||||
|
||||
Here an existing image is given to gnuplot verbatim, and data to plot on top of
|
||||
it is interpreted by feedgnuplot as usual. C<flipy> is useful here because
|
||||
|
@@ -21,6 +21,7 @@ complete -W \
|
||||
--set \
|
||||
--unset \
|
||||
--equation \
|
||||
--image \
|
||||
--geometry \
|
||||
--hardcopy \
|
||||
--help \
|
||||
|
@@ -33,6 +33,7 @@ _arguments -S
|
||||
'*--set[Additional 'set' gnuplot commands]:set-option' \
|
||||
'*--unset[Additional 'unset' gnuplot commands]:unset-option' \
|
||||
'*--equation[Raw symbolic equation]:equation' \
|
||||
'--image[Image file to render beneath the data]:image' \
|
||||
'--square[Plot data with square aspect ratio]' \
|
||||
'--square_xy[For 3D plots, set square aspect ratio for ONLY the x,y axes]' \
|
||||
'--hardcopy[Plot to a file]:filename' \
|
||||
|
Reference in New Issue
Block a user