added --equation-above and --equation-below

This commit is contained in:
Dima Kogan 2021-02-20 18:48:36 -08:00
parent 3c8c84ed59
commit 5a608b72b9
4 changed files with 37 additions and 3 deletions

View File

@ -99,6 +99,8 @@ sub interpretCommandline
$options{set} = []; $options{set} = [];
$options{unset} = []; $options{unset} = [];
$options{equation} = []; $options{equation} = [];
$options{'equation-below'} = [];
$options{'equation-above'} = [];
$options{curvestyleall} = ''; $options{curvestyleall} = '';
$options{styleall} = ''; $options{styleall} = '';
@ -120,7 +122,7 @@ sub interpretCommandline
'style=s{2}', 'curvestyle=s{2}', 'curvestyleall=s', 'styleall=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@',
'every=s{2}', 'everyall=s', 'every=s{2}', 'everyall=s',
'square!', 'square_xy!', 'square-xy!', 'squarexy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!', 'timefmt=s', 'square!', 'square_xy!', 'square-xy!', 'squarexy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!', 'timefmt=s',
'equation=s@', 'equation=s@', 'equation-below=s@', 'equation-above=s@',
'image=s', 'image=s',
'histogram=s@', 'binwidth=f', 'histstyle=s', 'histogram=s@', 'binwidth=f', 'histstyle=s',
'terminal=s', 'terminal=s',
@ -503,6 +505,10 @@ sub interpretCommandline
unshift @{$options{equation}}, qq{"$options{image}" binary filetype=auto flipy with rgbimage title "$options{image}"}; unshift @{$options{equation}}, qq{"$options{image}" binary filetype=auto flipy with rgbimage title "$options{image}"};
delete $options{image}; delete $options{image};
} }
# --equation-below is a synonym of --equation
push @{$options{equation}}, @{$options{'equation-below'}};
@{$options{'equation-below'}} = [];
} }
sub getGnuplotVersion sub getGnuplotVersion
@ -1157,6 +1163,7 @@ sub plotStoredData
my $body = join('', map { "$_," } @{$options{equation}}); my $body = join('', map { "$_," } @{$options{equation}});
$body .= join(', ' , map({ "'-' $_" } @extraopts) ); $body .= join(', ' , map({ "'-' $_" } @extraopts) );
$body .= join('', map { ",$_" } @{$options{'equation-above'}});
if($options{'3d'}) { print PIPE "splot $body\n"; } if($options{'3d'}) { print PIPE "splot $body\n"; }
else { print PIPE "plot $body\n"; } else { print PIPE "plot $body\n"; }
@ -2079,6 +2086,8 @@ the y-axis extents are not specified (C<--ymin>, C<--ymax>, C<--set 'yrange
properly. Since this option is just a passthrough to gnuplot, finer control can properly. Since this option is just a passthrough to gnuplot, finer control can
be achieved by passing in C<--equation> and C<--set yrange ...> directly. be achieved by passing in C<--equation> and C<--set yrange ...> directly.
=item
C<--equation xxx> C<--equation xxx>
Gnuplot can plot both data and symbolic equations. C<feedgnuplot> generally Gnuplot can plot both data and symbolic equations. C<feedgnuplot> generally
@ -2107,6 +2116,18 @@ points, and I I<also> plot a true circle as a parametric equation.
=item =item
C<--equation-below xxx>
Synonym for C<--equation>. These are rendered I<below> all the other data.
=item
C<--equation-above xxx>
Like C<--equation>, but is rendered I<on top> of all the other data.
=item
C<--square> C<--square>
Plot data with aspect ratio 1. For 3D plots, this controls the aspect ratio for Plot data with aspect ratio 1. For 3D plots, this controls the aspect ratio for

View File

@ -25,6 +25,8 @@ complete -W \
--set \ --set \
--unset \ --unset \
--equation \ --equation \
--equation-below \
--equation-above \
--image \ --image \
--geometry \ --geometry \
--hardcopy \ --hardcopy \

View File

@ -39,6 +39,8 @@ _arguments -S
'*--set[Additional 'set' gnuplot commands]:set-option' \ '*--set[Additional 'set' gnuplot commands]:set-option' \
'*--unset[Additional 'unset' gnuplot commands]:unset-option' \ '*--unset[Additional 'unset' gnuplot commands]:unset-option' \
'*--equation[Raw symbolic equation]:equation' \ '*--equation[Raw symbolic equation]:equation' \
'*--equation-below[Raw symbolic equation]:equation' \
'*--equation-above[Raw symbolic equation to plot on top]:equation' \
'--image[Image file to render beneath the data]:image:_files -g "(#i)*.(jpg|jpeg|png|gif)"' \ '--image[Image file to render beneath the data]:image:_files -g "(#i)*.(jpg|jpeg|png|gif)"' \
'--square[Plot data with square aspect ratio]' \ '--square[Plot data with square aspect ratio]' \
'--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]' \

View File

@ -39,7 +39,7 @@ BEGIN {
} }
} }
use Test::More tests => 82; use Test::More tests => 84;
use File::Temp 'tempfile'; use File::Temp 'tempfile';
use IPC::Run 'run'; use IPC::Run 'run';
use String::ShellQuote; use String::ShellQuote;
@ -279,6 +279,15 @@ tryplot( testname => 'xticlabels styles with tuplesize',
'--ymax', '6'], '--ymax', '6'],
refplot => 'xticlabels-styles-with-tuplesize.ref' ); refplot => 'xticlabels-styles-with-tuplesize.ref' );
tryplot( testname => 'equations',
cmd => qq{seq 10 15},
options => [qw(--equation x),
qw(--equation-above x+1),
qw(--equation-below x-1),
'--with', 'boxes fill solid border lt -1',
'--ymin', '0'],
refplot => 'equations.ref' );
SKIP: SKIP:
{ {