title: gnuplot: apply colornames from datafile
body: <p>How can I take colornames from a datafile?
  I didn't expect this to be so difficult, but apparently it is.
  Why do version 1 and version 2 give wrong colors? Is there a simpler way to achieve correct colors without using arrays as in version 3? And <code>...lc var</code> only works with index values but not with colornames.</p>
  
  <pre><code>### colornames from data
  reset session
  
  $Data &lt;&lt;EOD
  1   40  orange
  2   35  cyan
  3   25  red
  4   15  yellow
  5   5   green
  EOD
  
  set yrange [0:]
  set multiplot layout 3,1
  MyColor = "black"
  plot \
      $Data u 1:(MyColor=strcol(3),$2):(0.7) w boxes fs solid 1.0 lc rgb MyColor notitle,\
      $Data u 1:($2/2):(strcol(3)) with labels tc rgb "white" notitle
  
  plot \
      for [i=1:|$Data|] $Data u (MyColor=strcol(3),$1):2:(0.7) every ::i-1::i-1 w boxes fs solid 1.0 lc rgb MyColor notitle,\
      $Data u 1:($2/2):(strcol(3)) with labels notitle
  
  array MyColors[|$Data|]
  plot \
      $Data u (NaN):(MyColors[$0+1]=strcol(3)) notitle,\
      for [i=1:|$Data|] $Data u 1:2:(0.7) every ::i-1::i-1 w boxes fs solid 1.0 lc rgb MyColors[i] notitle,\
      $Data u 1:($2/2):(strcol(3)) with labels notitle
  
  print MyColors
  unset multiplot
  ### end of code
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/f0e36.png" rel="noreferrer"><img src="https://i.stack.imgur.com/f0e36.png" alt="enter image description here"></a></p>