|
From: Ethan M. <merritt@u.washington.edu> - 2010-02-12 22:40:18
|
On Friday 12 February 2010 11:26:36 Teo S Bernhard wrote: > > > the below shortened example reproducing the error message: > > > > > > > > > # file: trial.gpl > > > f(x)=x > > > plot a=1, \ > > > f(x)*a title "data from index a=1" w l lw 2 lt a , a=a+1, \ > > > f(x)*a title "data from index a=2" w l lw 2 lt a , a=a+1, \ > > > a=0 > > > > Please see Bug #2907028 > > > > https://sourceforge.net/tracker/?func=detail&aid=2907028&group_id=2055&atid=102055 > > > > So far as I can tell from running old versions of gnuplot (back to 3.7), > > it never did work correctly to increment a variable multiple times inside > > a plot command. > > > > > Test of referred bug report: > I have tested and it is is reproducible. There is however a subtle > difference with my example and that of the bug report. Note that I initiate > the counter variable first in the plot command. Then - the problem vanish. > The parameter incrementation is then correct! > You can convince yourself by trying the following: > > k=0 > plot [0:1] [-1:] k=0, \ > k*x t '0x' w lp lt 1, k=k+1, \ > k*x t '1x' w lp lt 2, k=k+1, \ > k*x t '2x' w lp lt 3 > > Now, if you remove the initial 'k=0, \' part of the plot-command - the > '0x'-line is plotted as 2*x, the '1x'-line as 3*x and '2x'-line as 4*x. Can > this be related to the two 'k=k+1' for some strange reason? In deed, adding > a third 'k=k+1' leads the first '0x'-line to be plotted as 3*x! This is > clearly a bug since k is expected as zero for the first line to be plotted, > '0x'. > > I therefore think there are two issues here: > 1) The issue reported as Bug #2907028 and > 2) the issue reported by me here, that version 4.4 does not allow an > increment as the last statement of a plot-command. The 4.0 and 4.2 documentation gives: Syntax: plot {<ranges>} {<function> | {"<datafile>" {datafile-modifiers}}} {axes <axes>} {<title-spec>} {with <style>} {, {definitions,} <function> ...} which means that definitions can come before a function, but not after. So I think you have been depending on undocumented, probably unintended, behavior. It may well be that some earlier versions did accept a trailing definition, but since it was not documented no one was testing for this as the code evolved. If there were no better way to accomplish what you were doing, I would agree that it was a bug and should be fixed. But since this can now be done more conveniently in 4.4 using iteration, I don't see much incentive to go back and reconstruct how earlier versions worked on an undocumented command syntax. What do others think? Is there good reason to rework the code to allow this, and change the documentation to match? Ethan > > This test on Ubuntu 8.04, gnuplot 4.2 patchlevel 2 and gnuplot 4.3 > patchlevel 0. > > > pause -1 "Continue?" > > > > > > # > > > # gnuplot 4.2 patchlevel 5 accepts the above. I believe that also > > > # gnuplot 4.3 accepted this. > > > # > > > # gnuplot-4.4.0 patchlevel 0-rc1 give error: > > > # "trial.gpl", line 6: function to plot expected > > > # > > > # > > > # It works if I add a dummy curve after a=0, so that last line > > > # becomes: > > > # a=0, x/0 > > > # > > > exit > > > > > > Best regards > > > Teo > > > > > > > |