This question is related to gnuplot histogram: How to put values on top of bars.
I have a datafile file.dat
:
x y1 y2
1 2 3
2 3 4
3 4 5
and the gnuplot:
set style data histogram;
set style histogram rowstacked;
plot newhistogram 'foo', 'file.dat' u 2:xtic(1) t col, '' u 3 t col;
Now I want to place the sums of columns 2 and 3 above the bars. The obvious solution
plot newhistogram 'foo', 'file.dat' u 2:xtic(1) t col, '' u 3 t col, \
'' u ($0-1):($2+$3+0.2):($2+$3) notitle w labels font "Arial,8";
puts the labels in the correct place, but the calculated sum is wrong. That is, in ($0-1):($2+$3+0.2):($2+$3)
, the second $2
appears to evaluate to zero.
What's going wrong here and how do I fix it?