|
From: Teo S B. <teo...@gm...> - 2010-02-14 19:08:16
|
2010/2/14 Hans-Bernhard Bröker <HBB...@t-...>:
> Ethan Merritt wrote:
>> 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
>
> I see no particularly compelling reason why this can't be changed to
>
> a=0 ; plot \
> 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 = 0
>
> Note the semicolons.
>
> The whole purpose of changing variables' values in the plot command is
> for that to take effect _between_ datasets/functions. There's no need
> at all for that to be possible before the first, or after the last of them.
Your suggestion breaks gridding/zooming/... capability in the plot.
This happens because the a-variable is not initiated within the plot statement.
I find when trying: a=0; plot [0:1] a*x, a=a+1, a*x
- while toggling the grid I see that the first plot shows '1x' and
2x, while the second version shows: '3x' and '4x'.
Note also that current gnuplot capability _does_ support initial
variable/function initiation, e.g.: plot [0:1] a=1, a*x, a=a+1,
a*x
- even according to documentation, see below.
>> So I think you have been depending on undocumented, probably unintended behavior.
The sole issue of mine is that gnuplot version 4.4 rc1 breaks backward
compatibility since it is
_not_ allowing trailing variable definitions as the last item of
plot-command. Such trailing definitions are
in much use here.
I certainly agree that there are fully functional workarounds even
with the suggested gnuplot 4.4-0 rc1 .
The downside is that any such workaround could imply reworking
historic scripts or other tools that
uses gnuplot as plotting engine and this particular feature. I claim
below - that it is gnuplot 4.4.0 rc1
that is at odds with the documentation.
>
>> What do others think? Is there good reason to rework the code to allow
>> this, and change the documentation to match?
>
I have been routinely using as _the_plotting_engine since 1999 and I
appreciate your great efforts in maintaining and further improving it.
Whatever your decision, I trust that it will be to the best for the
future of gnuplot.
As to the issue of "trailing definitions", the following is my
argument for why I think that a "trailing definition" should be
allowed:.
I believe that the suggested change is required by the documentation,
I read in gnuplot 4.4 rc 1 under 'help plot':
a) definitions can come initially in plot command, see the example
no. 3: plot f(x) = sin(x*a), a = .2, f(x), a = .4, f(x)
b) definitions can come between prior and subsequent functions if
separated by a comma, this is also explicitly said in the help text
c) In the briefer usage instruction (repeated below) I notice the
optional trailing comma after definitions {,}, I also notice the
replaceable <function>.
Considering the interpretation of item c), practical experience with
gnuplot versions 4.3, 4.2, 4.0,..., suggest that there is no need for
a trailing comma after a definition if there is no trailing
<function>, here <function> can be replaced by nothing. In my opinion,
the latter is a reasonable interpretation which is supported by
historic gnuplot implementations. See the brief usage instruction:
plot {<ranges>}
{<iteration>}
{<function> | {"<datafile>" {datafile-modifiers}}}
{axes <axes>} {<title-spec>} {with <style>}
{, {definitions{,}} <function> ...}
My claim is therefore that previous gnuplot version, prior to gnuplot
4.4 rc1, behaved according to this documentation whereas version 4.4
rc 1 does not behave according to the documentation regarding item c,
this causes gnuplot 4.4 rc1 to break backwards compatibility.
If you agree, please consider the following patch vs. gnuplot 4.4 rc1
for allowing trailing definitions in a plot command: plot [-1:1] k=0,
k*x, k=k+1, k*x, k=k+1
As can be seen, only one code line needs to be modified - in two
places. The modified if-statement is the one that causes an error
message.
With this modification, a trailing definition is silently accepted
whereas earlier syntax errors are triggered as before.
Best regards
Teo
(Linux, Ubuntu 9.10 and self-compiled gnuplot 4.4.0 rc1)
diff -r ca8b5fbc043a plot2d.c
--- a/plot2d.c Sun Feb 14 14:45:12 2010 +0100
+++ b/plot2d.c Sun Feb 14 16:45:27 2010 +0100
@@ -1459,7 +1459,7 @@
if (is_definition(c_token)) {
define();
- if (!equals(c_token,",")) {
+ if (!END_OF_COMMAND && !equals(c_token,",")) {
was_definition = TRUE;
continue;
}
@@ -2174,7 +2174,7 @@
if (is_definition(c_token)) {
define();
- if (!equals(c_token,",")) {
+ if (!END_OF_COMMAND && !equals(c_token,",")) {
was_definition = TRUE;
continue;
}
|