Compare commits

...

7 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
5 changed files with 142 additions and 19 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. --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. 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 --curvestyle curveID style
Additional styles per curve. With --dataid, curveID is the 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. --curvestyleall xxx Additional styles for ALL curves.
--extracmds xxx Additional commands. These could contain extra global styles --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 --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 --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 --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, --maxcurves xxx The maximum allowed number of curves. This is 100 by default,
but can be reset with this option. This exists purely to but can be reset with this option. This exists purely to

View File

@@ -89,19 +89,24 @@ sub interpretCommandline
# do not stream in the data by default # do not stream in the data by default
# point plotting by default. # point plotting by default.
# no monotonicity checks by default # no monotonicity checks by default
# normal histograms by default
$options{ maxcurves } = 100; $options{ maxcurves } = 100;
$options{ histstyle} = 'freq';
# Previously I was using 'legend=s%' and 'curvestyle=s%' for curve addressing. This had cleaner # 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 # syntax, but disregarded the order of the given options. This resulted in arbitrarily ordered
# curves. # curves.
# needed for these to be parsed into a ref to a list # needed for these to be parsed into a ref to a list
$options{legend} = []; $options{legend} = [];
$options{curvestyle} = []; $options{curvestyle} = [];
$options{histogram} = [];
GetOptions($options, 'stream:s', 'domain!', 'dataid!', '3d!', 'colormap!', 'lines!', 'points!', GetOptions($options, 'stream:s', 'domain!', 'dataid!', '3d!', 'colormap!', 'lines!', 'points!',
'circles', 'legend=s{2}', 'autolegend!', 'xlabel=s', 'ylabel=s', 'y2label=s', 'zlabel=s', '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', '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@', 'zmin=f', 'zmax=f', 'y2=s@', 'curvestyle=s{2}', 'curvestyleall=s', 'extracmds=s@',
'size=s', 'square!', 'square_xy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!', 'size=s', 'square!', 'square_xy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!',
'histogram=s@', 'binwidth=f', 'histstyle=s',
'terminal=s',
'extraValuesPerPoint=i', 'help', 'dump', 'extraValuesPerPoint=i', 'help', 'dump',
'geometry=s') or pod2usage(1); 'geometry=s') or pod2usage(1);
@@ -112,6 +117,12 @@ sub interpretCommandline
# no global style if one isn't given # no global style if one isn't given
$options->{curvestyleall} = '' unless defined $options->{curvestyleall}; $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' # parse stream option. Allowed only numbers >= 0 or 'trigger'
if(defined $options->{stream}) if(defined $options->{stream})
{ {
@@ -177,6 +188,12 @@ sub interpretCommandline
print STDERR "--3d does not make sense with --monotonic\n"; print STDERR "--3d does not make sense with --monotonic\n";
exit -1; exit -1;
} }
if ( defined $options->{binwidth} || @{$options->{histogram}} )
{
print STDERR "--3d does not make sense with histograms\n";
exit -1;
}
} }
else else
{ {
@@ -204,6 +221,12 @@ sub interpretCommandline
# --xlen implies an order to the data, so I force monotonicity # --xlen implies an order to the data, so I force monotonicity
$options{monotonic} = 1 if defined $options{xlen}; $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 sub getGnuplotVersion
@@ -264,22 +287,25 @@ sub mainThread
if( $options{hardcopy}) if( $options{hardcopy})
{ {
$outputfile = $options{hardcopy}; $outputfile = $options{hardcopy};
($outputfileType) = $outputfile =~ /\.(eps|ps|pdf|png)$/; $outputfile =~ /\.(eps|ps|pdf|png|svg)$/i;
if(!$outputfileType) { die("Only .eps, .ps, .pdf and .png supported\n"); } $outputfileType = $1 ? lc $1 : '';
my %terminalOpts = my %terminalOpts =
( eps => 'postscript solid color enhanced eps', ( eps => 'postscript solid color enhanced eps',
ps => 'postscript solid color landscape 10', ps => 'postscript solid color landscape 10',
pdf => 'pdfcairo solid color font ",10" size 11in,8.5in', 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"; $options{terminal} ||= $terminalOpts{$outputfileType}
print PIPE "set output \"$outputfile\"\n"; if $terminalOpts{$outputfileType};
}
else 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 x11\n";
} }
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 # If a bound isn't given I want to set it to the empty string, so I can communicate it simply to
# gnuplot # gnuplot
@@ -387,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 # regexp for a possibly floating point, possibly scientific notation number
my $numRE = '-?\d*\.?\d+(?:[Ee][-+]?\d+)?'; my $numRE = '-?\d*\.?\d+(?:[Ee][-+]?\d+)?';
@@ -564,7 +600,9 @@ sub updateCurveOptions
my $titleoption = defined $title ? "title \"$title\"" : "notitle"; my $titleoption = defined $title ? "title \"$title\"" : "notitle";
my $extraoption = defined $options{curvestyleall} ? $options{curvestyleall} : ''; 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 sub getCurve
@@ -609,6 +647,16 @@ sub setCurveLabel
updateCurveOptions($curve->[0], $id); 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 # remove all the curve data
sub clearCurves sub clearCurves
{ {
@@ -919,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. --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. 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 --curvestyle curveID style
Additional styles per curve. With --dataid, curveID is the Additional styles per curve. With --dataid, curveID is the
@@ -929,7 +1000,8 @@ As an example, if line 3 of the input is "0 9 1 20"
--curvestyleall xxx Additional styles for ALL curves. --curvestyleall xxx Additional styles for ALL curves.
--extracmds xxx Additional commands. These could contain extra global styles --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 --size xxx Gnuplot size option
@@ -939,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 --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 --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, --maxcurves xxx The maximum allowed number of curves. This is 100 by default,
but can be reset with this option. This exists purely to but can be reset with this option. This exists purely to

View File

@@ -37,4 +37,8 @@ complete -W \
--dump \ --dump \
--geometry \ --geometry \
--curvestyle \ --curvestyle \
--histogram \
--binwidth \
--histstyle \
--terminal \
--legend' feedgnuplot --legend' feedgnuplot

View File

@@ -3,7 +3,7 @@
_arguments -S \ _arguments -S \
'()--domain[first element of each line is the domain variable]' \ '()--domain[first element of each line is the domain variable]' \
'--dataid[each data point is preceded by the corresponding ID]' \ '--dataid[each data point is preceded by the corresponding ID]' \
'(--monotonic --xlen)--3d' \ '(--monotonic --xlen --histogram)--3d' \
'--colormap[show a colormapped xy plot]' \ '--colormap[show a colormapped xy plot]' \
'--stream[Plot the data in realtime]::period in s:' \ '--stream[Plot the data in realtime]::period in s:' \
'--lines' \ '--lines' \
@@ -38,4 +38,8 @@ _arguments -S
'--dump[Instead of printing to gnuplot, print to STDOUT]' \ '--dump[Instead of printing to gnuplot, print to STDOUT]' \
'--geometry[The X11 geometry string]:geometry string:' \ '--geometry[The X11 geometry string]:geometry string:' \
'*--curvestyle[Additional styles for a curve]:curve id: :style:' \ '*--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:' '*--legend[Legend for a curve]:curve id: :legend:'

9
debian/changelog vendored
View File

@@ -1,3 +1,12 @@
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 feedgnuplot (1.19) unstable; urgency=low
* added --geometry option to specify plot dimensions * added --geometry option to specify plot dimensions