diff --git a/bin/feedgnuplot b/bin/feedgnuplot index ec28eee..5c8fb99 100755 --- a/bin/feedgnuplot +++ b/bin/feedgnuplot @@ -99,6 +99,8 @@ sub interpretCommandline $options{set} = []; $options{unset} = []; $options{equation} = []; + $options{'equation-below'} = []; + $options{'equation-above'} = []; $options{curvestyleall} = ''; $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@', 'every=s{2}', 'everyall=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', 'histogram=s@', 'binwidth=f', 'histstyle=s', 'terminal=s', @@ -503,6 +505,10 @@ sub interpretCommandline unshift @{$options{equation}}, qq{"$options{image}" binary filetype=auto flipy with rgbimage title "$options{image}"}; delete $options{image}; } + + # --equation-below is a synonym of --equation + push @{$options{equation}}, @{$options{'equation-below'}}; + @{$options{'equation-below'}} = []; } sub getGnuplotVersion @@ -1156,7 +1162,8 @@ sub plotStoredData my @extraopts = map {$_->{options}} @nonemptyCurves; 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"; } 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 be achieved by passing in C<--equation> and C<--set yrange ...> directly. +=item + C<--equation xxx> Gnuplot can plot both data and symbolic equations. C generally @@ -2107,6 +2116,18 @@ points, and I I plot a true circle as a parametric equation. =item +C<--equation-below xxx> + +Synonym for C<--equation>. These are rendered I all the other data. + +=item + +C<--equation-above xxx> + +Like C<--equation>, but is rendered I of all the other data. + +=item + C<--square> Plot data with aspect ratio 1. For 3D plots, this controls the aspect ratio for diff --git a/completions/bash/feedgnuplot b/completions/bash/feedgnuplot index e11bedf..a9840b3 100644 --- a/completions/bash/feedgnuplot +++ b/completions/bash/feedgnuplot @@ -25,6 +25,8 @@ complete -W \ --set \ --unset \ --equation \ + --equation-below \ + --equation-above \ --image \ --geometry \ --hardcopy \ diff --git a/completions/zsh/_feedgnuplot b/completions/zsh/_feedgnuplot index 9d4c87c..1ab075c 100644 --- a/completions/zsh/_feedgnuplot +++ b/completions/zsh/_feedgnuplot @@ -39,6 +39,8 @@ _arguments -S '*--set[Additional 'set' gnuplot commands]:set-option' \ '*--unset[Additional 'unset' gnuplot commands]:unset-option' \ '*--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)"' \ '--square[Plot data with square aspect ratio]' \ '--square-xy[For 3D plots, set square aspect ratio for ONLY the x,y axes]' \ diff --git a/t/plots.t b/t/plots.t index 9612b10..6b0a169 100644 --- a/t/plots.t +++ b/t/plots.t @@ -39,7 +39,7 @@ BEGIN { } } -use Test::More tests => 82; +use Test::More tests => 84; use File::Temp 'tempfile'; use IPC::Run 'run'; use String::ShellQuote; @@ -279,6 +279,15 @@ tryplot( testname => 'xticlabels styles with tuplesize', '--ymax', '6'], 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: {