0
votes

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: Table aligned with key

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 siunitx, amsmath etc.), the alignment is achieved via a combination of sprintf and \tabular:

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}$ & $\\delta / \\si{\\per\\cm}$ & $s / \\si{\\per\\cm}$ \\\\ \\num{%.2f} & \\num{%.2f} & \\num{%.3f} \\\\ & & \\end{tabular}",I_1,d_1,s_1), \
0.8 lw 3 t sprintf("\\begin{tabular}{ccc} \\parbox{\\widthof{$I_{rel}$}}{~} & \\parbox{\\widthof{$\\delta / \\si{\\per\\cm}$}}{~} & \\parbox{\\widthof{$s / \\si{\\per\\cm}$}}{~} \\\\ \\num{%.2f} & \\num{%.2f} & \\num{%.3f} \\\\ & & \\end{tabular}",I_2,d_2,s_2), \
0.7 lw 3 t sprintf("\\begin{tabular}{ccc} \\parbox{\\widthof{$I_{rel}$}}{~} & \\parbox{\\widthof{$\\delta / \\si{\\per\\cm}$}}{~} & \\parbox{\\widthof{$s / \\si{\\per\\cm}$}}{~} \\\\ \\num{%.2f} & \\num{%.2f} & \\num{%.3f} \\\\ & & \\end{tabular}",I_3,d_3,s_3)

set term epslatex colour rounded
set out "gnuplot-table.tex"
replot

Each 'title' contains its own 3-row-\tabular: 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.

Although my code is working, it is very messy and only poorly customizable. Does anyone have a better idea of achieving this?

1

1 Answers

0
votes

To get a "table header" in your key you could plot a white point or line outside of the plotting range and make the title of this graph your desired header. Then plot the rest like you do, but without the three row tables. You have a header and everything should align well.

Also move set term and set out to the top of the script and remove replot, if there is no reason that i don't know of to design it like this.