Outside of loops, dashtype can be set using a string or an even-length tuple of lengths:
set dashtype 1 "- "
set dashtype 1 (1,2)
However, in a loop, only the string variant seems to work. These two commands are accepted:
set for [i=1:3] dashtype i "- "
do for [i=1:3] { set dashtype i "- " }
But the following commands fail with the message undefined function: i
:
set for [i=1:3] dashtype i (1,2)
do for [i=1:3] { set dashtype i (1,2) }
It would be nice to have both variants available in loops. If this is intentionally unsupported, it would be good to have a more appropriate error message.
The behavior reproduces on gnuplot 6.0 patchlevel 3
and on current master (63af8b2e7bf7dcb25cb4783476342e8c782516be
).
The problem here is not the loop. The problem is that the command
set dashtype i (1,2)
looks to gnuplot like the start of a command that invokes a 2-parameter functioni(x,y)
to find out what dashtype is being set. As in the hypothetical sequence of commandsSo this is a language design error. I'll have to think about whether there is a fix, and also whether the same ambiguity exists for other "set" commands.
Fixed now.
A possible work-around for existing gnuplot versions is to put the iteration variable in parentheses.