|
|
|
@@ -14,7 +14,7 @@ use Text::ParseWords; # for shellwords
|
|
|
|
|
use Pod::Usage;
|
|
|
|
|
use Time::Piece;
|
|
|
|
|
|
|
|
|
|
my $VERSION = 1.35;
|
|
|
|
|
my $VERSION = 1.37;
|
|
|
|
|
|
|
|
|
|
my %options;
|
|
|
|
|
interpretCommandline();
|
|
|
|
@@ -89,6 +89,7 @@ sub interpretCommandline
|
|
|
|
|
$options{extracmds} = [];
|
|
|
|
|
$options{set} = [];
|
|
|
|
|
$options{unset} = [];
|
|
|
|
|
$options{equation} = [];
|
|
|
|
|
|
|
|
|
|
$options{curvestyleall} = '';
|
|
|
|
|
$options{styleall} = '';
|
|
|
|
@@ -102,6 +103,7 @@ sub interpretCommandline
|
|
|
|
|
'zmin=f', 'zmax=f', 'y2=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',
|
|
|
|
|
'equation=s@',
|
|
|
|
|
'histogram=s@', 'binwidth=f', 'histstyle=s',
|
|
|
|
|
'terminal=s',
|
|
|
|
|
'rangesize=s{2}', 'rangesizeall=i', 'extraValuesPerPoint=i',
|
|
|
|
@@ -550,7 +552,7 @@ sub mainThread
|
|
|
|
|
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}})
|
|
|
|
|
{
|
|
|
|
|
# @{$options{legend}} is a list where consecutive pairs are (curveID,
|
|
|
|
@@ -565,7 +567,7 @@ sub mainThread
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# add the extra curve options
|
|
|
|
|
# add the extra curve options
|
|
|
|
|
if(@{$options{curvestyle}})
|
|
|
|
|
{
|
|
|
|
|
# @{$options{curvestyle}} is a list where consecutive pairs are (curveID,
|
|
|
|
@@ -580,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}});
|
|
|
|
|
|
|
|
|
|
# timefmt
|
|
|
|
|
# timefmt
|
|
|
|
|
if( $options{timefmt} )
|
|
|
|
|
{
|
|
|
|
|
print(PIPE "set timefmt '$options{timefmt}'\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 "set $_\n") foreach (@{$options{set}});
|
|
|
|
|
print(PIPE "unset $_\n") foreach (@{$options{unset}});
|
|
|
|
|
|
|
|
|
|
# set up histograms
|
|
|
|
|
# set up histograms
|
|
|
|
|
$options{binwidth} ||= 1; # if no binwidth given, set it to 1
|
|
|
|
|
print PIPE
|
|
|
|
|
"set boxwidth $options{binwidth}\n" .
|
|
|
|
@@ -603,7 +605,7 @@ sub mainThread
|
|
|
|
|
|
|
|
|
|
setCurveAsHistogram( $_ ) foreach (@{$options{histogram}});
|
|
|
|
|
|
|
|
|
|
# set all the axis ranges
|
|
|
|
|
# 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";
|
|
|
|
@@ -747,7 +749,7 @@ sub mainThread
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# finished reading in all. Plot what we have
|
|
|
|
|
plotStoredData() unless $options{stream};
|
|
|
|
|
plotStoredData() unless $options{stream} && $options{exit};
|
|
|
|
|
|
|
|
|
|
if ( defined $options{hardcopy})
|
|
|
|
|
{
|
|
|
|
@@ -818,7 +820,9 @@ sub plotStoredData
|
|
|
|
|
my @nonemptyCurves = grep { $_->{datastring} } @curves;
|
|
|
|
|
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"; }
|
|
|
|
|
else { print PIPE "plot $body\n"; }
|
|
|
|
|
|
|
|
|
@@ -1537,12 +1541,17 @@ in the plot. Defaults to 1.0 if not given.
|
|
|
|
|
|
|
|
|
|
C<--histstyle style>
|
|
|
|
|
|
|
|
|
|
Normally, histograms are generated with the 'smooth freq' gnuplot style.
|
|
|
|
|
C<--histstyle> can be used to select different 'smooth' settings. Allowed are
|
|
|
|
|
'unique', 'cumulative' and 'cnormal'. 'unique' indicates whether a bin has at
|
|
|
|
|
least one item in it: instead of counting the items, it'll always report 0 or 1.
|
|
|
|
|
'cumulative' is the integral of the "normal" histogram. 'cnormal' is like
|
|
|
|
|
'cumulative', but rescaled to end up at 1.0.
|
|
|
|
|
Normally, histograms are generated with the 'smooth frequency' gnuplot style.
|
|
|
|
|
C<--histstyle> can be used to select different C<smooth> settings (see the
|
|
|
|
|
gnuplot C<help smooth> page for more info). Allowed values are 'frequency' (the
|
|
|
|
|
default), 'unique', 'cumulative' and 'cnormal'. 'unique' indicates whether a bin
|
|
|
|
|
has at least one item in it: instead of counting the items, it'll always report
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
@@ -1610,6 +1619,34 @@ times.
|
|
|
|
|
|
|
|
|
|
=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>
|
|
|
|
|
|
|
|
|
|
Plot data with aspect ratio 1. For 3D plots, this controls the aspect ratio for
|
|
|
|
|