title: gnuplot: align table with key
body: <p>I have some experimental data and want to fit a function f(x;I,d,s) several times to it. Each fit produces a set of parameters; let's assume I fitted 3 times and ended up with in total 9 parameters: I_1, I_2 … s_3. I want to display the values in a 3*3 table that has some descriptive header with each set of parameters being aligned to its sample in the key: <a href="http://i.stack.imgur.com/0mb3N.png" rel="nofollow">Table aligned with key</a></p>
  
  <p>For simplicity I just displayed 3 horizontal lines without the data and defined the variables rather than actually fitting them. I am post-processing the plot with LaTeX (and packages like <code>siunitx</code>, <code>amsmath</code> etc.), the alignment is achieved via a combination of <code>sprintf</code> and <code>\tabular</code>:</p>
  
  <pre><code>set key bottom left Left reverse spacing 1.25
  set yrange [0:1]
  set termopt noenhanced
  I_1=608.18
  d_1=0.61
  s_1=0.005
  I_2=607.53
  d_2=0.61
  s_2=0.005
  I_3=611.97
  d_3=0.63
  s_3=0.004
  
  plot 0.9 lw 3 t sprintf("\\begin{tabular}{ccc} $I_{rel}$ &amp; $\\delta / \\si{\\per\\cm}$ &amp; $s / \\si{\\per\\cm}$ \\\\ \\num{%.2f} &amp; \\num{%.2f} &amp; \\num{%.3f} \\\\ &amp; &amp; \\end{tabular}",I_1,d_1,s_1), \
  0.8 lw 3 t sprintf("\\begin{tabular}{ccc} \\parbox{\\widthof{$I_{rel}$}}{~} &amp; \\parbox{\\widthof{$\\delta / \\si{\\per\\cm}$}}{~} &amp; \\parbox{\\widthof{$s / \\si{\\per\\cm}$}}{~} \\\\ \\num{%.2f} &amp; \\num{%.2f} &amp; \\num{%.3f} \\\\ &amp; &amp; \\end{tabular}",I_2,d_2,s_2), \
  0.7 lw 3 t sprintf("\\begin{tabular}{ccc} \\parbox{\\widthof{$I_{rel}$}}{~} &amp; \\parbox{\\widthof{$\\delta / \\si{\\per\\cm}$}}{~} &amp; \\parbox{\\widthof{$s / \\si{\\per\\cm}$}}{~} \\\\ \\num{%.2f} &amp; \\num{%.2f} &amp; \\num{%.3f} \\\\ &amp; &amp; \\end{tabular}",I_3,d_3,s_3)
  
  set term epslatex colour rounded
  set out "gnuplot-table.tex"
  replot
  </code></pre>
  
  <p>Each 'title' contains its own 3-row-<code>\tabular</code>: the first row contains empty spaces with the length of the table header, the second one the actual numbers, and the third one is completely empty. The former is needed for proper vertical centering of numbers and header, while the latter is needed for the second row to be horizontally aligned with the key sample.</p>
  
  <p>Although my code is working, it is very messy and only poorly customizable. Does anyone have a better idea of achieving this?</p>