|
From: <pl...@pi...> - 2016-09-17 10:28:59
|
Hi,
the iteration in gnupllot is an excellent feature but can not take an
irregular sequence of numerical variables.
it's either a straight integer series or a list of _string_ variables.
Is there any reason why it can not take a list of numbers ?
eg. if I want vertical arrows at x= 11,13,17 it does not seem
possible with the existing iteration.
help tells me:
Two forms of iteration clause are currently supported:
for [intvar = start:end{:increment}]
for [stringvar in "A B C D"]
why not for [intvar = 11,13,17] ?
is there a trick to a string value in set arrow ?
set for [stringvar in "11 13 17"] arrow from ???, 0 to ???,1
Is there a problem to specify intvar with a list of values instead of a
regular series?
Thanks, Peter.
|
|
From: sfeam <sf...@us...> - 2016-09-17 17:31:49
|
On Saturday, 17 September 2016 10:52:20 AM pl...@pi... wrote:
> Hi,
>
>
> the iteration in gnupllot is an excellent feature but can not take an
> irregular sequence of numerical variables.
>
> it's either a straight integer series or a list of _string_ variables.
>
>
> Is there any reason why it can not take a list of numbers ?
>
> eg. if I want vertical arrows at x= 11,13,17 it does not seem
> possible with the existing iteration.
>
>
> help tells me:
>
> Two forms of iteration clause are currently supported:
>
> for [intvar = start:end{:increment}]
> for [stringvar in "A B C D"]
>
>
>
>
> why not for [intvar = 11,13,17] ?
>
>
> is there a trick to a string value in set arrow ?
>
> set for [stringvar in "11 13 17"] arrow from ???, 0 to ???,1
Works for me:
gnuplot> set for [a in "11 13 17"] arrow from a,0 to a,1
gnuplot> show arrow
arrow 1, head nofilled back lt black linewidth 1.000 dashtype solid
from (11.0000, 0.00000, 0.00000) to (11.0000, 1.00000, 0.00000)
arrow 2, head nofilled back lt black linewidth 1.000 dashtype solid
from (13.0000, 0.00000, 0.00000) to (13.0000, 1.00000, 0.00000)
arrow 3, head nofilled back lt black linewidth 1.000 dashtype solid
from (17.0000, 0.00000, 0.00000) to (17.0000, 1.00000, 0.00000)
> Is there a problem to specify intvar with a list of values instead of a
> regular series?
In the development version you could use an array:
array list[3] = [11, 13, 17];
set for [i=1:3] arrow from list[i],0 to list[i],1
This could probably be extended a bit.
For example:
cleanly handling empty array slots,
allowing [1:*] to represent the full array,
promoting the array name into the iterator: for [i indexing array] ...
Ethan
|
|
From: <pl...@pi...> - 2016-09-17 22:45:36
|
On 17/09/16 18:12, sfeam wrote: > gnuplot> set for [a in "11 13 17"] arrow from a,0 to a,1 Many thanks Ethan. , I have to admit I did not try that since I consult the doc when I don't know syntax and do not waste time doing other things than what is documented in the wild hope of discovering undocumented features. So we have a documentation bug , that syntax is not proposed for intvar and apparently it should be. I did do a fair bit of searching trying to find a work around or a trick and did not find anything. So it looks like most people like me believe what they read and are not profiting form this excellent feature. Regards. Peter. |
|
From: sfeam <sf...@us...> - 2016-09-18 00:01:18
|
On Saturday, 17 September 2016 08:09:09 PM pl...@pi... wrote:
> On 17/09/16 18:12, sfeam wrote:
> > gnuplot> set for [a in "11 13 17"] arrow from a,0 to a,1
>
>
> Many thanks Ethan. , I have to admit I did not try that since I consult
> the doc when I don't know syntax and do not waste time doing other
> things than what is documented in the wild hope of discovering
> undocumented features.
>
> So we have a documentation bug , that syntax is not proposed for intvar
> and apparently it should be.
Not exactly. It's more of an unintended (but useful) consequence of
promotion from string to integer wherever the program knows that a
number is expected.
In the above example a is a string variable not an integer variable.
But the "set arrow" command is looking for a number, not a string,
so it does the conversion silently. Just as the following both work
plot foo lt 2
plot foo lt "2"
This does _not_ work for floating point number however.
That's why I think it might be a good idea to allow iteration over
the elements in an array. Then you could have something like
array value[3] = [1.11, 2.22, 3.33]
plot for [V in value] f(V)
> I did do a fair bit of searching trying to find a work around or a trick
> and did not find anything. So it looks like most people like me believe
> what they read and are not profiting form this excellent feature.
>
> Regards. Peter.
|