Compare commits

...

11 Commits

Author SHA1 Message Date
Dima Kogan
2b2a40f1fe version bump 2012-08-31 01:36:23 -07:00
Dima Kogan
dd034797ec updated completions with the new options 2012-08-31 01:35:16 -07:00
Dima Kogan
c89ddef9ba POD update 2012-08-31 01:25:13 -07:00
Dima Kogan
f4859ae475 --extracmds, --histogram, --y2 can now take comma-separated lists 2012-08-31 01:24:49 -07:00
Dima Kogan
69c635103a generic terminals can now be requested 2012-08-31 01:05:58 -07:00
Dima Kogan
8952973ba2 added histogram support 2012-08-31 00:51:08 -07:00
Dima Kogan
e14b57b6ad no longer hardcoding 'x11' as the default terminal 2012-07-24 17:38:22 -07:00
Dima Kogan
7141538258 POD update 2012-02-11 21:05:33 -08:00
Dima Kogan
970364289d changelog bump 2012-02-11 21:05:07 -08:00
Dima Kogan
e8e54edd9d made consistent my email addy in the debian changelog 2012-02-11 21:03:53 -08:00
Dima Kogan
e30f0c792e added --geometry option to specify plot dimensions 2012-02-11 20:48:22 -08:00
5 changed files with 161 additions and 23 deletions

View File

@@ -292,7 +292,30 @@ As an example, if line 3 of the input is "0 9 1 20"
--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.
Does not apply to 3d plots. Can be passed multiple times, or passed a
comma-separated list
--histogram curveID
Set up a this specific curve to plot a histogram. The bin
width is given with the --binwidth option (assumed 1.0 if
omitted). --histogram does NOT touch the drawing style.
It is often desired to plot these with boxes, and this
MUST be explicitly requested with --curvestyleall 'with
boxes'. This works with --domain and/or --stream, but in
those cases the x-value is used ONLY to cull old data
because of --xlen or --monotonic. I.e. the x-values are
NOT drawn in any way. Can be passed multiple times, or passed a comma-
separated list
--binwidth width The width of bins when making histograms. This setting applies to ALL
histograms in the plot. Defaults to 1.0 if not given.
--histstyle style Normally, histograms are generated with the 'smooth freq'
gnuplot style. --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.
--curvestyle curveID style
Additional styles per curve. With --dataid, curveID is the
@@ -302,7 +325,8 @@ As an example, if line 3 of the input is "0 9 1 20"
--curvestyleall xxx Additional styles for ALL curves.
--extracmds xxx Additional commands. These could contain extra global styles
for instance
for instance. Can be passed multiple times, or passed a comma-
separated list
--size xxx Gnuplot size option
@@ -312,7 +336,12 @@ As an example, if line 3 of the input is "0 9 1 20"
--square_xy For 3D plots, set square aspect ratio for ONLY the x,y axes
--hardcopy xxx If not streaming, output to a file specified here. Format
inferred from filename
inferred from filename, unless specified by --terminal
--terminal xxx String passed to 'set terminal'. No attempts are made to
validate this. --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
--hardcopy and --terminal
--maxcurves xxx The maximum allowed number of curves. This is 100 by default,
but can be reset with this option. This exists purely to
@@ -337,6 +366,8 @@ As an example, if line 3 of the input is "0 9 1 20"
--dump Instead of printing to gnuplot, print to STDOUT. For
debugging.
--geometry If using X11, specifies the size, position of the plot window
=head1 ACKNOWLEDGEMENT
This program is originally based on the driveGnuPlots.pl script from

View File

@@ -89,20 +89,26 @@ sub interpretCommandline
# do not stream in the data by default
# point plotting by default.
# no monotonicity checks by default
# normal histograms by default
$options{ maxcurves } = 100;
$options{ histstyle} = 'freq';
# Previously I was using 'legend=s%' and 'curvestyle=s%' for curve addressing. This had cleaner
# syntax, but disregarded the order of the given options. This resulted in arbitrarily ordered
# curves.
# needed for these to be parsed into a ref to a list
$options{legend} = [];
$options{curvestyle} = [];
$options{legend} = [];
$options{curvestyle} = [];
$options{histogram} = [];
GetOptions($options, 'stream:s', 'domain!', 'dataid!', '3d!', 'colormap!', 'lines!', 'points!',
'circles', 'legend=s{2}', 'autolegend!', 'xlabel=s', 'ylabel=s', 'y2label=s', 'zlabel=s',
'title=s', 'xlen=f', 'ymin=f', 'ymax=f', 'xmin=f', 'xmax=f', 'y2min=f', 'y2max=f',
'zmin=f', 'zmax=f', 'y2=s@', 'curvestyle=s{2}', 'curvestyleall=s', 'extracmds=s@',
'size=s', 'square!', 'square_xy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!',
'extraValuesPerPoint=i', 'help', 'dump') or pod2usage(1);
'histogram=s@', 'binwidth=f', 'histstyle=s',
'terminal=s',
'extraValuesPerPoint=i', 'help', 'dump',
'geometry=s') or pod2usage(1);
# handle various cmdline-option errors
if ( $options->{help} )
@@ -111,6 +117,12 @@ sub interpretCommandline
# no global style if one isn't given
$options->{curvestyleall} = '' unless defined $options->{curvestyleall};
# expand options that are given as comma-separated lists
for my $listkey (qw(extracmds histogram y2))
{
@{$options{$listkey}} = map split('\s*,\s*', $_), @{$options{$listkey}};
}
# parse stream option. Allowed only numbers >= 0 or 'trigger'
if(defined $options->{stream})
{
@@ -176,6 +188,12 @@ sub interpretCommandline
print STDERR "--3d does not make sense with --monotonic\n";
exit -1;
}
if ( defined $options->{binwidth} || @{$options->{histogram}} )
{
print STDERR "--3d does not make sense with histograms\n";
exit -1;
}
}
else
{
@@ -203,6 +221,12 @@ sub interpretCommandline
# --xlen implies an order to the data, so I force monotonicity
$options{monotonic} = 1 if defined $options{xlen};
if( $options{histstyle} !~ /freq|cum|uniq|cnorm/ )
{
print STDERR "unknown histstyle. Allowed are 'freq...', 'cum...', 'uniq...', 'cnorm...'\n";
exit -1;
}
}
sub getGnuplotVersion
@@ -252,7 +276,9 @@ sub mainThread
}
else
{
open PIPE, "|gnuplot $dopersist" or die "Can't initialize gnuplot\n";
my $geometry = defined $options{geometry} ?
"-geometry $options{geometry}" : '';
open PIPE, "|gnuplot $geometry $dopersist" or die "Can't initialize gnuplot\n";
}
autoflush PIPE 1;
@@ -261,22 +287,25 @@ sub mainThread
if( $options{hardcopy})
{
$outputfile = $options{hardcopy};
($outputfileType) = $outputfile =~ /\.(eps|ps|pdf|png)$/;
if(!$outputfileType) { die("Only .eps, .ps, .pdf and .png supported\n"); }
$outputfile =~ /\.(eps|ps|pdf|png|svg)$/i;
$outputfileType = $1 ? lc $1 : '';
my %terminalOpts =
( eps => 'postscript solid color enhanced eps',
ps => 'postscript solid color landscape 10',
pdf => 'pdfcairo solid color font ",10" size 11in,8.5in',
png => 'png size 1280,1024' );
png => 'png size 1280,1024',
svg => 'svg');
print PIPE "set terminal $terminalOpts{$outputfileType}\n";
print PIPE "set output \"$outputfile\"\n";
}
else
{
print PIPE "set terminal x11\n";
$options{terminal} ||= $terminalOpts{$outputfileType}
if $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};
}
print PIPE "set terminal $options{terminal}\n" if $options{terminal};
print PIPE "set output \"$outputfile\"\n" if $outputfile;
# If a bound isn't given I want to set it to the empty string, so I can communicate it simply to
# gnuplot
@@ -384,6 +413,16 @@ sub mainThread
}
}
# set up histograms
$options{binwidth} ||= 1; # if no binwidth given, set it to 1
print PIPE
"set boxwidth $options{binwidth}\n" .
"histbin(x) = $options{binwidth} * floor(0.5 + x/$options{binwidth})\n";
foreach (@{$options{histogram}})
{
setCurveAsHistogram( $_ );
}
# regexp for a possibly floating point, possibly scientific notation number
my $numRE = '-?\d*\.?\d+(?:[Ee][-+]?\d+)?';
@@ -561,7 +600,9 @@ sub updateCurveOptions
my $titleoption = defined $title ? "title \"$title\"" : "notitle";
my $extraoption = defined $options{curvestyleall} ? $options{curvestyleall} : '';
$curveoptions->{options} = "$titleoption $curveoptions->{extraoptions} $extraoption";
my $histoptions = $curveoptions->{histoptions} || '';
$curveoptions->{options} = "$histoptions $titleoption $curveoptions->{extraoptions} $extraoption";
}
sub getCurve
@@ -606,6 +647,16 @@ sub setCurveLabel
updateCurveOptions($curve->[0], $id);
}
sub setCurveAsHistogram
{
my ($id, $str) = @_;
my $curve = getCurve($id);
$curve->[0]{histoptions} = 'using (histbin($2)):(1.0) smooth ' . $options{histstyle};
updateCurveOptions($curve->[0], $id);
}
# remove all the curve data
sub clearCurves
{
@@ -916,7 +967,30 @@ As an example, if line 3 of the input is "0 9 1 20"
--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.
Does not apply to 3d plots. Can be passed multiple times, or passed a
comma-separated list
--histogram curveID
Set up a this specific curve to plot a histogram. The bin
width is given with the --binwidth option (assumed 1.0 if
omitted). --histogram does NOT touch the drawing style.
It is often desired to plot these with boxes, and this
MUST be explicitly requested with --curvestyleall 'with
boxes'. This works with --domain and/or --stream, but in
those cases the x-value is used ONLY to cull old data
because of --xlen or --monotonic. I.e. the x-values are
NOT drawn in any way. Can be passed multiple times, or passed a comma-
separated list
--binwidth width The width of bins when making histograms. This setting applies to ALL
histograms in the plot. Defaults to 1.0 if not given.
--histstyle style Normally, histograms are generated with the 'smooth freq'
gnuplot style. --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.
--curvestyle curveID style
Additional styles per curve. With --dataid, curveID is the
@@ -926,7 +1000,8 @@ As an example, if line 3 of the input is "0 9 1 20"
--curvestyleall xxx Additional styles for ALL curves.
--extracmds xxx Additional commands. These could contain extra global styles
for instance
for instance. Can be passed multiple times, or passed a comma-
separated list
--size xxx Gnuplot size option
@@ -936,7 +1011,12 @@ As an example, if line 3 of the input is "0 9 1 20"
--square_xy For 3D plots, set square aspect ratio for ONLY the x,y axes
--hardcopy xxx If not streaming, output to a file specified here. Format
inferred from filename
inferred from filename, unless specified by --terminal
--terminal xxx String passed to 'set terminal'. No attempts are made to
validate this. --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
--hardcopy and --terminal
--maxcurves xxx The maximum allowed number of curves. This is 100 by default,
but can be reset with this option. This exists purely to
@@ -961,6 +1041,8 @@ As an example, if line 3 of the input is "0 9 1 20"
--dump Instead of printing to gnuplot, print to STDOUT. For
debugging.
--geometry If using X11, specifies the size, position of the plot window
=head1 ACKNOWLEDGEMENT
This program is originally based on the driveGnuPlots.pl script from

View File

@@ -35,5 +35,10 @@ complete -W \
--monotonic \
--extraValuesPerPoint \
--dump \
--geometry \
--curvestyle \
--histogram \
--binwidth \
--histstyle \
--terminal \
--legend' feedgnuplot

View File

@@ -3,7 +3,7 @@
_arguments -S \
'()--domain[first element of each line is the domain variable]' \
'--dataid[each data point is preceded by the corresponding ID]' \
'(--monotonic --xlen)--3d' \
'(--monotonic --xlen --histogram)--3d' \
'--colormap[show a colormapped xy plot]' \
'--stream[Plot the data in realtime]::period in s:' \
'--lines' \
@@ -36,5 +36,10 @@ _arguments -S
'(--3d)--monotonic[Resets plot if an X in the past is seen]' \
'--extraValuesPerPoint[How many extra values are given for each data point]:' \
'--dump[Instead of printing to gnuplot, print to STDOUT]' \
'--geometry[The X11 geometry string]:geometry string:' \
'*--curvestyle[Additional styles for a curve]:curve id: :style:' \
'(--3d)*--histogram:plot to treat as a histogram:' \
'--binwidth:Histogram bin width:' \
'--histstyle:Style of histogram:(frequency unique cumulative cnormal)' \
'--terminal:Terminal options to set with "set terminal":' \
'*--legend[Legend for a curve]:curve id: :legend:'

19
debian/changelog vendored
View File

@@ -1,9 +1,24 @@
feedgnuplot (1.20) unstable; urgency=low
* no longer hardcoding 'x11' as the default terminal
* added histogram support
* generic terminals can now be requested
* --extracmds, --histogram, --y2 can now take comma-separated lists
-- Dima Kogan <dima@secretsauce.net> Fri, 31 Aug 2012 01:35:50 -0700
feedgnuplot (1.19) unstable; urgency=low
* added --geometry option to specify plot dimensions
-- Dima Kogan <dima@secretsauce.net> Sat, 11 Feb 2012 21:04:42 -0800
feedgnuplot (1.18) unstable; urgency=low
* data-ids can now include characters such as -. Any non-whitespace
works
-- Dima Kogan <dkogan@secretsauce.net> Tue, 27 Dec 2011 16:47:36 -0800
-- Dima Kogan <dima@secretsauce.net> Tue, 27 Dec 2011 16:47:36 -0800
feedgnuplot (1.17) unstable; urgency=low
@@ -14,7 +29,7 @@ feedgnuplot (1.17) unstable; urgency=low
[ Hermann Schwarting ]
* add build dependency libtest-script-run-perl
-- Dima Kogan <dkogan@secretsauce.net> Sun, 20 Nov 2011 19:17:22 -0800
-- Dima Kogan <dima@secretsauce.net> Sun, 20 Nov 2011 19:17:22 -0800
feedgnuplot (1.16) unstable; urgency=low