title: GNUPlot - Arbitrary number of columns in stacked line
body: <p>I am working on a script that generates a csv with arbitrary number of y values for a given x value. The first row of the csv has the names of the data sets. The x value is a unix timestamp. I would like to use gnuplot to graph this data as a stacked line graph where the values are shown as fractions of a total for that row. How would I do this?</p>
  
  <p>I've looked at the following solutions, and attempted to integrate them, but I cannot figure out  what I am doing wrong.</p>
  
  <p>It will either say not enough columns or some mismatch for the number of columns.</p>
  
  <p>There are up to N columns of data for a given time index. The total I am looking at is for a given time index.</p>
  
  <p>--</p>
  
  <p>An example of my data:</p>
  
  <pre><code>KEY,CSS,JavaScript,Perl,Python,Shell
  1428852630,0,0,0,0,406
  1428852721,0,0,0,0,406
  1428852793,0,0,0,0,406
  1428853776,0,0,0,0,781
  1429889154,0,0,0,0,1200
  1429891056,0,0,0,0,1648
  1429891182,0,0,0,0,1648
  1429891642,0,0,0,0,1648
  1430176065,0,0,0,0,2056
  </code></pre>
  
  <p>However, there might be a large number of columns, I want one that sets the number of columns on run time.</p>
  
  <hr>
  
  <p><a href="http://gnuplot.sourceforge.net/demo/histograms.html" rel="nofollow">http://gnuplot.sourceforge.net/demo/histograms.html</a> - This seems  to have issues with being modified to have an arbitrary number of columns.</p>
  
  <pre><code>plot 'immigration.dat' using (100.*$2/$24):xtic(1) t column(2), \
      for [i=3:23] '' using (100.*column(i)/column(24)) title column(i)
  </code></pre>
  
  <p><a href="https://newspaint.wordpress.com/2013/09/11/creating-a-filled-stack-graph-in-gnuplot/" rel="nofollow">https://newspaint.wordpress.com/2013/09/11/creating-a-filled-stack-graph-in-gnuplot/</a></p>