added --style, --styleall

This commit is contained in:
Dima Kogan 2014-01-24 15:29:27 -08:00
parent 35901fe6d1
commit c21c4d7e70
3 changed files with 61 additions and 30 deletions

View File

@ -110,6 +110,7 @@ sub interpretCommandline
# needed for these to be parsed into an array-ref, these default to [] # needed for these to be parsed into an array-ref, these default to []
$options{legend} = []; $options{legend} = [];
$options{curvestyle} = []; $options{curvestyle} = [];
$options{style} = [];
$options{histogram} = []; $options{histogram} = [];
$options{y2} = []; $options{y2} = [];
$options{extracmds} = []; $options{extracmds} = [];
@ -117,13 +118,14 @@ sub interpretCommandline
$options{unset} = []; $options{unset} = [];
$options{curvestyleall} = ''; $options{curvestyleall} = '';
$options{styleall} = '';
$options{with} = ''; $options{with} = '';
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',
'zmin=f', 'zmax=f', 'y2=s@', 'zmin=f', 'zmax=f', 'y2=s@',
'curvestyle=s{2}', 'curvestyleall=s', 'with=s', 'extracmds=s@', 'set=s@', 'unset=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', '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',
@ -154,6 +156,22 @@ sub interpretCommandline
if defined $options{$listkey}; if defined $options{$listkey};
} }
# --style and --curvestyle are synonyms, as are --styleall and
# --curvestyleall, so fill that in
if( $options{styleall} )
{
if($options{curvestyleall} )
{
$options{curvestyleall} .= " $options{styleall}";
}
else
{
$options{curvestyleall} = $options{styleall};
}
}
push @{$options{curvestyle}}, @{$options{style}};
# --legend and --curvestyle options are conceptually hashes, but are parsed as # --legend and --curvestyle options are conceptually hashes, but are parsed as
# 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
@ -1038,21 +1056,20 @@ points. New curves will be created as needed.
The most commonly used functionality of gnuplot is supported directly by the The most commonly used functionality of gnuplot is supported directly by the
script. Anything not directly supported can still be done with options such as script. Anything not directly supported can still be done with options such as
C<--set>, C<--extracmds> C<--curvestyle>, etc. Arbitrary gnuplot commands can be C<--set>, C<--extracmds> C<--style>, etc. Arbitrary gnuplot commands can be
passed in with C<--extracmds>. For example, to turn off the grid, you can pass passed in with C<--extracmds>. For example, to turn off the grid, you can pass
in C<--extracmds 'unset grid'>. Commands C<--set> and C<--unset> exists to in C<--extracmds 'unset grid'>. Commands C<--set> and C<--unset> exists to
provide nicer syntax, so this is equivalent to passing C<--unset grid>. As many provide nicer syntax, so this is equivalent to passing C<--unset grid>. As many
of these options as needed can be passed in. To add arbitrary curve styles, use of these options as needed can be passed in. To add arbitrary curve styles, use
C<--curvestyle curveID extrastyle>. Pass these more than once to affect more C<--style curveID extrastyle>. Pass these more than once to affect more than one
than one curve. curve.
To apply an extra style to I<all> the curves that lack an explicit To apply an extra style to I<all> the curves that lack an explicit C<--style>,
C<--curvestyle>, pass in C<--curvestyleall extrastyle>. In the most common case, pass in C<--styleall extrastyle>. In the most common case, the extra style is
the extra style is C<with something>. To support this more simply, you can pass C<with something>. To support this more simply, you can pass in C<--with
in C<--with something> instead of C<--curvestyleall 'with something'>. something> instead of C<--styleall 'with something'>. C<--styleall> and
C<--curvestyleall> and C<--with> are mutually exclusive. Furthermore any C<--with> are mutually exclusive. Furthermore any curve-specific C<--style>
curve-specific C<--curvestyle> overrides the global C<--curvestyleall> or overrides the global C<--styleall> or C<--with> setting.
C<--with> setting.
=head2 Data formats =head2 Data formats
@ -1099,14 +1116,13 @@ to represent a single point. For example, the script has support to plot all the
data with C<--circles>. This requires a radius to be specified for each point in data with C<--circles>. This requires a radius to be specified for each point in
addition to the position of the point. Thus, when plotting with C<--circles>, 2 addition to the position of the point. Thus, when plotting with C<--circles>, 2
numbers are read for each data point instead of 1. A similar situation exists numbers are read for each data point instead of 1. A similar situation exists
with C<--colormap> where each point contains the position I<and> the with C<--colormap> where each point contains the position I<and> the color.
color. There are other gnuplot styles that require more data (such as error There are other gnuplot styles that require more data (such as error bars), but
bars), but none of these are directly supported by the script. They can still be none of these are directly supported by the script. They can still be used,
used, though, by specifying the specific style with C<--curvestyle>, and though, by specifying the specific style with C<--style>, and specifying how
specifying how many extra values are needed for each point with many extra values are needed for each point with C<--extraValuesPerPoint extra>.
C<--extraValuesPerPoint extra>. C<--extraValuesPerPoint> is ONLY needed for the C<--extraValuesPerPoint> is ONLY needed for the styles not explicitly supported;
styles not explicitly supported; supported styles set that variable supported styles set that variable automatically.
automatically.
=head3 3D data =head3 3D data
@ -1437,7 +1453,7 @@ feedgnuplot the curves plotted on the y2 axis were drawn with a thicker line.
This is no longer the case, but that behavior can be brought back by passing This is no longer the case, but that behavior can be brought back by passing
something like something like
--y2 curveid --curvestyle curveid 'linewidth 3' --y2 curveid --style curveid 'linewidth 3'
=item =item
@ -1472,33 +1488,44 @@ least one item in it: instead of counting the items, it'll always report 0 or 1.
=item =item
--style curveID style
Additional styles per curve. With --dataid, curveID is the ID. Otherwise, it's
the index of the curve, starting at 0. Use this option multiple times for
multiple curves. --styleall does I<not> apply to curves that have a --style
=item
--curvestyle curveID --curvestyle curveID
style Additional styles per curve. With --dataid, curveID is the ID. Otherwise, Synonym for C<--style>
it's the index of the curve, starting at 0. Use this option multiple times for
multiple curves. --curvestylall does NOT apply to curves that have a =item
--curvestyle
--styleall xxx
Additional styles for all curves that have no C<--style>. This is overridden by
any applicable C<--style>. Exclusive with C<--with>.
=item =item
--curvestyleall xxx --curvestyleall xxx
Additional styles for all curves that have no --curvestyle. This is overridden Synonym for C<--styleall>
by any applicable C<--curvestyle>. Exclusive with C<--with>.
=item =item
--with xxx --with xxx
Same as C<--curvestyleall>, but prefixed with "with". Thus Same as C<--styleall>, but prefixed with "with". Thus
--with boxes --with boxes
is equivalent to is equivalent to
--curvestyleall 'with boxes' --styleall 'with boxes'
Exclusive with C<--curvestyleall>. Exclusive with C<--styleall>.
=item =item
@ -1577,7 +1604,7 @@ How many extra values are given for each data point. Normally this is 0, and
does not need to be specified, but sometimes we want extra data, like for colors does not need to be specified, but sometimes we want extra data, like for colors
or point sizes or error bars, etc. feedgnuplot options that require this or point sizes or error bars, etc. feedgnuplot options that require this
(colormap, circles) automatically set it. This option is ONLY needed if unknown (colormap, circles) automatically set it. This option is ONLY needed if unknown
styles are used, with C<--curvestyleall> or C<--with> for instance styles are used, with C<--styleall> or C<--with> for instance
=item =item

View File

@ -7,6 +7,8 @@ complete -W \
--colormap \ --colormap \
--curvestyle \ --curvestyle \
--curvestyleall \ --curvestyleall \
--style \
--styleall \
--with \ --with \
--dataid \ --dataid \
--domain \ --domain \

View File

@ -27,6 +27,7 @@ _arguments -S
'--zmax:max Z:' \ '--zmax:max Z:' \
'*--y2:plot to place on the Y2 axis:' \ '*--y2:plot to place on the Y2 axis:' \
'(--with)--curvestyleall[Additional styles for ALL curves]:style' \ '(--with)--curvestyleall[Additional styles for ALL curves]:style' \
'(--with)--styleall[Additional styles for ALL curves]:style' \
'(--curvestyleall)--with[Additional styles for ALL curves]:style' \ '(--curvestyleall)--with[Additional styles for ALL curves]:style' \
'*--extracmds[Additional gnuplot commands]:command' \ '*--extracmds[Additional gnuplot commands]:command' \
'*--set[Additional 'set' gnuplot commands]:set-option' \ '*--set[Additional 'set' gnuplot commands]:set-option' \
@ -40,6 +41,7 @@ _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:' \
'*--style[Additional styles for a curve]:curve id: :style:' \
'(--3d)*--histogram:plot to treat as a histogram:' \ '(--3d)*--histogram:plot to treat as a histogram:' \
'--binwidth:Histogram bin width:' \ '--binwidth:Histogram bin width:' \
'--histstyle:Style of histogram:(frequency unique cumulative cnormal)' \ '--histstyle:Style of histogram:(frequency unique cumulative cnormal)' \