title: setting variables with gnuplot's for cycle
body: <p>I am trying to set variables for gnuplot environment with <strong>set for cycle</strong> command. 
  I am using 4.6 version and according the <a href="http://www.google.cz/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CFgQFjAA&amp;url=http%3A%2F%2Fwww.gnuplot.info%2Fdocs_4.6%2Fgnuplot.pdf&amp;ei=9EHjT_yuEI31sgac1uzBBg&amp;usg=AFQjCNGIBRhbpB8my3nC1akK7rLPFSWCKQ&amp;sig2=hoNqqc-j-Kp0oJoCtZDO7w" rel="nofollow">gnuplot documention (page 70)</a> the syntax is following:</p>
  
  <pre><code>for [intvar = start:end{:increment}]
  for [stringvar in "A B C D"]
  Examples:
  set for [i = 1:10] style line i lc rgb "blue"
  </code></pre>
  
  <p>But i get this error:</p>
  
  <pre><code>gnuplot&gt; set for [var in gpvars] replace(var,'#_#',' ')
                                   ^
           line 0: Unrecognized option.  See 'help set'.
  </code></pre>
  
  <p>My script:</p>
  
  <pre><code>#!/bin/bash
  
  OUTDIRNAME="out"
  TIMEFORMAT='%d.%m.%y'
  GPPARS=( "xlabel "Time"" "ylabel "value1"" "y2label "value2"" "format x "%H:%M"")
  GPPARS_MOD=()
  
  for (( i=0; i &lt; ${#GPPARS[@]}; i++)); do 
    FILE=${GPPARS[${i}]}
    echo "arg=${FILE}"
    GPPARS_MOD+=( "`echo "${FILE}" | sed -e 's/ /#_#/g'`" )
  done
  
  gnuplot &lt;&lt; EOF
  reset
  
  replace(S,C,R)=(strstrt(S,C)) ? \
      replace( S[:strstrt(S,C)-1].R.S[strstrt(S,C)+strlen(C):] ,C,R) : S
  
  set terminal png
  set output "${OUTDIRNAME}/graph.png"
  set timefmt "${TIMEFORMAT}"
  set xdata time
  
  gpvars="${GPPARS_MOD[@]}"
  
  set for [var in gpvars] {
     replace(var,'#_#',' ')
  }
  
  ...
  
  EOF
  
  ...
  
  exit 0 
  </code></pre>
  
  <p>I am also using function replace, because spaces ( gnuplot ignores escape sequences )The function works flawlessly for plot for cycle.
  I have tried with and without function and with variables without spaces, but the result is same.</p>