mirror of
https://github.com/dkogan/feedgnuplot.git
synced 2025-05-06 06:21:16 +08:00
added --rangesize and --rangesizeall
--rangesizeall is a different way to express --extraValuesPerPoint. --rangesize is per-curve however
This commit is contained in:
parent
4163e24956
commit
4fd1c390ff
100
bin/feedgnuplot
100
bin/feedgnuplot
@ -121,6 +121,8 @@ sub interpretCommandline
|
|||||||
$options{styleall} = '';
|
$options{styleall} = '';
|
||||||
$options{with} = '';
|
$options{with} = '';
|
||||||
|
|
||||||
|
$options{rangesize} = [];
|
||||||
|
|
||||||
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=s', 'xmax=s', 'y2min=f', 'y2max=f',
|
'title=s', 'xlen=f', 'ymin=f', 'ymax=f', 'xmin=s', 'xmax=s', 'y2min=f', 'y2max=f',
|
||||||
@ -129,7 +131,8 @@ sub interpretCommandline
|
|||||||
'square!', 'square_xy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!', 'timefmt=s',
|
'square!', 'square_xy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!', 'timefmt=s',
|
||||||
'histogram=s@', 'binwidth=f', 'histstyle=s',
|
'histogram=s@', 'binwidth=f', 'histstyle=s',
|
||||||
'terminal=s',
|
'terminal=s',
|
||||||
'extraValuesPerPoint=i', 'help', 'dump', 'exit', 'version',
|
'rangesize=s{2}', 'rangesizeall=i', 'extraValuesPerPoint=i',
|
||||||
|
'help', 'dump', 'exit', 'version',
|
||||||
'geometry=s') or pod2usage( -exitval => 1,
|
'geometry=s') or pod2usage( -exitval => 1,
|
||||||
-verbose => 1, # synopsis and args
|
-verbose => 1, # synopsis and args
|
||||||
-output => \*STDERR );
|
-output => \*STDERR );
|
||||||
@ -176,7 +179,7 @@ sub interpretCommandline
|
|||||||
# arrays in order to preserve the ordering. I parse both of these into hashes
|
# arrays in order to preserve the ordering. I parse both of these into hashes
|
||||||
# because those are useful to have later. After this I can access individual
|
# because those are useful to have later. After this I can access individual
|
||||||
# legends with $options{legend_hash}{curveid}
|
# legends with $options{legend_hash}{curveid}
|
||||||
for my $listkey (qw(legend curvestyle))
|
for my $listkey (qw(legend curvestyle rangesize))
|
||||||
{
|
{
|
||||||
$options{"${listkey}_hash"} = {};
|
$options{"${listkey}_hash"} = {};
|
||||||
|
|
||||||
@ -193,6 +196,12 @@ sub interpretCommandline
|
|||||||
exit -1;
|
exit -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( defined $options{rangesizeall} && defined $options{extraValuesPerPoint} )
|
||||||
|
{
|
||||||
|
print STDERR "Only one of --rangesizeall and --extraValuesPerPoint may be given\n";
|
||||||
|
exit -1;
|
||||||
|
}
|
||||||
|
|
||||||
# parse stream option. Allowed only numbers >= 0 or 'trigger'. After this code
|
# parse stream option. Allowed only numbers >= 0 or 'trigger'. After this code
|
||||||
# $options{stream} is
|
# $options{stream} is
|
||||||
# -1 for triggered replotting
|
# -1 for triggered replotting
|
||||||
@ -425,10 +434,18 @@ sub makeDomainNumeric
|
|||||||
|
|
||||||
sub mainThread
|
sub mainThread
|
||||||
{
|
{
|
||||||
my $valuesPerPoint = 1;
|
my $valuesPerPoint;
|
||||||
|
if( $options{rangesizeall} )
|
||||||
|
{
|
||||||
|
$valuesPerPoint = $options{rangesizeall};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$valuesPerPoint = 1;
|
||||||
if($options{extraValuesPerPoint}) { $valuesPerPoint += $options{extraValuesPerPoint}; }
|
if($options{extraValuesPerPoint}) { $valuesPerPoint += $options{extraValuesPerPoint}; }
|
||||||
if($options{colormap}) { $valuesPerPoint++; }
|
if($options{colormap}) { $valuesPerPoint++; }
|
||||||
if($options{circles} ) { $valuesPerPoint++; }
|
if($options{circles} ) { $valuesPerPoint++; }
|
||||||
|
}
|
||||||
|
|
||||||
local *PIPE;
|
local *PIPE;
|
||||||
my $dopersist = '';
|
my $dopersist = '';
|
||||||
@ -703,21 +720,28 @@ sub mainThread
|
|||||||
|
|
||||||
while(@fields)
|
while(@fields)
|
||||||
{
|
{
|
||||||
|
my $rangesize = $valuesPerPoint;
|
||||||
|
|
||||||
if($options{dataid})
|
if($options{dataid})
|
||||||
{
|
{
|
||||||
last if @fields < 1 + $valuesPerPoint;
|
|
||||||
$id = shift @fields;
|
$id = shift @fields;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
last if @fields < $valuesPerPoint;
|
|
||||||
$id++;
|
$id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( $options{rangesize_hash}{$id} )
|
||||||
|
{
|
||||||
|
$rangesize = $options{rangesize_hash}{$id};
|
||||||
|
}
|
||||||
|
|
||||||
|
last if @fields < $rangesize;
|
||||||
|
|
||||||
pushPoint(getCurve($id),
|
pushPoint(getCurve($id),
|
||||||
join(' ',
|
join(' ',
|
||||||
@domain,
|
@domain,
|
||||||
splice( @fields, 0, $valuesPerPoint ) ) . "\n",
|
splice( @fields, 0, $rangesize ) ) . "\n",
|
||||||
$domain0_numeric);
|
$domain0_numeric);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1129,17 +1153,24 @@ conjunction with C<--dataid>.
|
|||||||
=head3 Multi-value style support
|
=head3 Multi-value style support
|
||||||
|
|
||||||
Depending on how gnuplot is plotting the data, more than one value may be needed
|
Depending on how gnuplot is plotting the data, more than one value may be needed
|
||||||
to represent a single point. For example, the script has support to plot all the
|
to represent the range of a single point. Basic 2D plots have 2 numbers
|
||||||
data with C<--circles>. This requires a radius to be specified for each point in
|
representing each point: 1 domain and 1 range. But if plotting with
|
||||||
addition to the position of the point. Thus, when plotting with C<--circles>, 2
|
C<--circles>, for instance, then there's an extra range value: the radius. A
|
||||||
numbers are read for each data point instead of 1. A similar situation exists
|
similar situation exists with C<--colormap> where each point contains the
|
||||||
with C<--colormap> where each point contains the position I<and> the color.
|
position I<and> the color. There are other gnuplot styles that require more data
|
||||||
There are other gnuplot styles that require more data (such as error bars), but
|
(such as error bars), but none of these are directly supported by the script.
|
||||||
none of these are directly supported by the script. They can still be used,
|
They can still be used, however, by specifying the specific style with
|
||||||
though, by specifying the specific style with C<--style>, and specifying how
|
C<--style>, and specifying how many values are needed for each point with
|
||||||
many extra values are needed for each point with C<--extraValuesPerPoint extra>.
|
C<--rangesizeall> or C<--rangesize> or C<--extraValuesPerPoint>. Those options
|
||||||
C<--extraValuesPerPoint> is ONLY needed for the styles not explicitly supported;
|
that specify the range size are required I<only> for styles not explicitly
|
||||||
supported styles set that variable automatically.
|
supported by feedgnuplot; supported styles do the right thing automatically.
|
||||||
|
|
||||||
|
More examples: if making a 2d plot of y error bars where gnuplot expects a
|
||||||
|
(x,y,ydelta) tuple for each point, you want C<--rangesizeall 2> because you have
|
||||||
|
one domain value (x) and 2 range values (y,ydelta). Gnuplot can also plot
|
||||||
|
lopsided y errorbars by giving a tuple (x,y,ylow,yhigh). This is similar as
|
||||||
|
before, but you want C<--rangesizeall 3> instead.
|
||||||
|
|
||||||
|
|
||||||
=head3 3D data
|
=head3 3D data
|
||||||
|
|
||||||
@ -1382,8 +1413,7 @@ Interpret the X data as a time/date, parsed with the given format
|
|||||||
C<--colormap>
|
C<--colormap>
|
||||||
|
|
||||||
Show a colormapped xy plot. Requires extra data for the color. zmin/zmax can be
|
Show a colormapped xy plot. Requires extra data for the color. zmin/zmax can be
|
||||||
used to set the extents of the colors. Automatically increments
|
used to set the extents of the colors. Automatically sets the C<--rangesize>.
|
||||||
C<--extraValuesPerPoint>
|
|
||||||
|
|
||||||
=item
|
=item
|
||||||
|
|
||||||
@ -1411,8 +1441,7 @@ Do [not] draw points
|
|||||||
C<--circles>
|
C<--circles>
|
||||||
|
|
||||||
Plot with circles. This requires a radius be specified for each point.
|
Plot with circles. This requires a radius be specified for each point.
|
||||||
Automatically increments C<--extraValuesPerPoint>). C<Not> supported for 3d
|
Automatically sets the C<--rangesize>. C<Not> supported for 3d plots.
|
||||||
plots.
|
|
||||||
|
|
||||||
=item
|
=item
|
||||||
|
|
||||||
@ -1616,13 +1645,32 @@ replotted before being purged
|
|||||||
|
|
||||||
=item
|
=item
|
||||||
|
|
||||||
|
C<--rangesize curveID xxx>
|
||||||
|
|
||||||
|
The options C<--rangesizeall>, C<--rangesize> and C<--extraValuesPerPoint> set
|
||||||
|
the number of values are needed to represent each point being plotted (see
|
||||||
|
L</"Multi-value style support"> above). These options are I<only> needed if
|
||||||
|
unknown styles are used, with C<--styleall> or C<--with> for instance.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
=item
|
||||||
|
|
||||||
|
C<--rangesizeall xxx>
|
||||||
|
|
||||||
|
Like C<--rangesize>, but applies to I<all> the curves.
|
||||||
|
|
||||||
C<--extraValuesPerPoint xxx>
|
C<--extraValuesPerPoint xxx>
|
||||||
|
|
||||||
How many extra values are given for each data point. Normally this is 0, and
|
Like C<--rangesizeall>, but instead of overriding the default, adds to it. For
|
||||||
does not need to be specified, but sometimes we want extra data, like for colors
|
example, if plotting non-lopsided y errorbars gnuplot wants (x,y,ydelta) tuples.
|
||||||
or point sizes or error bars, etc. feedgnuplot options that require this
|
These can be specified both with C<--rangesizeall 2> (because there are 2 range
|
||||||
(colormap, circles) automatically set it. This option is ONLY needed if unknown
|
values) or C<--extraValuesPerPoint 1> (because there's 1 more value than usual).
|
||||||
styles are used, with C<--styleall> or C<--with> for instance
|
|
||||||
|
This option is I<only> needed if unknown styles are used, with C<--styleall> or
|
||||||
|
C<--with> for instance.
|
||||||
|
|
||||||
=item
|
=item
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ complete -W \
|
|||||||
--dump \
|
--dump \
|
||||||
--exit \
|
--exit \
|
||||||
--extraValuesPerPoint \
|
--extraValuesPerPoint \
|
||||||
|
--rangesizeall \
|
||||||
|
--rangesize \
|
||||||
--extracmds \
|
--extracmds \
|
||||||
--set \
|
--set \
|
||||||
--unset \
|
--unset \
|
||||||
|
@ -37,7 +37,9 @@ _arguments -S
|
|||||||
'--hardcopy[Plot to a file]:filename' \
|
'--hardcopy[Plot to a file]:filename' \
|
||||||
'--maxcurves[The maximum allowed number of curves]:number of curves' \
|
'--maxcurves[The maximum allowed number of curves]:number of curves' \
|
||||||
'(--3d)--monotonic[Resets plot if an X in the past is seen]' \
|
'(--3d)--monotonic[Resets plot if an X in the past is seen]' \
|
||||||
'--extraValuesPerPoint[How many extra values are given for each data point]:N'\
|
'(--rangesizeall)--extraValuesPerPoint[How many extra values are given for each data range]:N'\
|
||||||
|
'(--extraValuesPerPoint)--rangesizeall[How many values are given for each data range]:N'\
|
||||||
|
'*--rangesize[How many values comprise a data range in this curve]:curve id: :N:' \
|
||||||
'--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:' \
|
||||||
|
99
t/plots.t
99
t/plots.t
@ -39,7 +39,7 @@ BEGIN {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use Test::More tests => 52;
|
use Test::More tests => 56;
|
||||||
use File::Temp 'tempfile';
|
use File::Temp 'tempfile';
|
||||||
use IPC::Run 'run';
|
use IPC::Run 'run';
|
||||||
use String::ShellQuote;
|
use String::ShellQuote;
|
||||||
@ -849,6 +849,103 @@ tryplot( testname => 'Error bars (using extraValuesPerPoint)',
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
tryplot( testname => 'Error bars (using rangesizeall)',
|
||||||
|
cmd => q{seq 5 | gawk '{print $1,$1,$1/10}'},
|
||||||
|
options => [qw(--domain),
|
||||||
|
qw(--rangesizeall 2 --with errorbars)],
|
||||||
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
|
|
||||||
|
5.5 ++---------+-----------+----------+----------+----------+-----------+----------+---------**
|
||||||
|
+ + + + + + + + *
|
||||||
|
| *
|
||||||
|
5 ++ +A
|
||||||
|
| *
|
||||||
|
| *
|
||||||
|
| *
|
||||||
|
4.5 ++ **
|
||||||
|
| *** |
|
||||||
|
| * |
|
||||||
|
4 ++ A ++
|
||||||
|
| * |
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
3.5 ++ ++
|
||||||
|
| *** |
|
||||||
|
| * |
|
||||||
|
3 ++ A ++
|
||||||
|
| * |
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
2.5 ++ ++
|
||||||
|
| |
|
||||||
|
| *** |
|
||||||
|
2 ++ A ++
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
| |
|
||||||
|
1.5 ++ ++
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
1 A* ++
|
||||||
|
** |
|
||||||
|
| |
|
||||||
|
+ + + + + + + + +
|
||||||
|
0.5 ++---------+-----------+----------+----------+----------+-----------+----------+---------++
|
||||||
|
1 1.5 2 2.5 3 3.5 4 4.5 5
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
tryplot( testname => 'Error bars (using rangesize, rangesizeall)',
|
||||||
|
cmd => q{seq 5 | gawk '{print $1,"vert",$1,$1/10,"horiz",5-$1,$1-$1/5,$1+$1/20}'},
|
||||||
|
options => [qw(--domain --dataid),
|
||||||
|
qw(--rangesize vert 2 --rangesizeall 3 --with xerrorbars --style vert), 'with errorbars',
|
||||||
|
qw(--xmin 1 --xmax 5 --ymin 0.5 --ymax 5.5)],
|
||||||
|
refplot => <<'EOF' );
|
||||||
|
|
||||||
|
|
||||||
|
+-----------+----------+-----------+----------+-----------+----------+-----------+---------**
|
||||||
|
+ + + + + + + + *
|
||||||
|
| *
|
||||||
|
5 ++ +A
|
||||||
|
| *
|
||||||
|
| *
|
||||||
|
| *
|
||||||
|
| **
|
||||||
|
| *** |
|
||||||
|
## * |
|
||||||
|
4 B# A ++
|
||||||
|
## * |
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
| |
|
||||||
|
| *** |
|
||||||
|
| # # * |
|
||||||
|
3 ++ #########B## A ++
|
||||||
|
| # # * |
|
||||||
|
| * |
|
||||||
|
| *** |
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
| *** # # |
|
||||||
|
2 ++ A ##############B### ++
|
||||||
|
| * # # |
|
||||||
|
| *** |
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
| # # |
|
||||||
|
1 A* ##################B##### ++
|
||||||
|
** # # |
|
||||||
|
| |
|
||||||
|
+ + + + + + + + +
|
||||||
|
+-----------+----------+-----------+----------+-----------+----------+-----------+----------+
|
||||||
|
1 1.5 2 2.5 3 3.5 4 4.5 5
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
SKIP:
|
SKIP:
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user