For this you must know, that with the histogram
style the boxes are placed at the x-positions 0
, 1
, etc. i.e. at the row number.
So for the errorbars
you must use column(0)
as x-coordinate:
set terminal pngcairo
set output "sample.png"
set boxwidth 0.75 relative
set style fill pattern 0 border
set style histogram rowstacked
set style data histograms
set yrange [0:150]
set macros
scale = '100/(column(2)+column(3)+column(4))'
set bars 2.0
plot 'data.dat' using ($2 * @scale):xtic(1) t "A" , \
'' using ($3 * @scale) t "B" , \
'' using ($4 * @scale) t "C",\
'' using 0:(100):5 with errorbars notitle lw 2 lt -1
The result with 4.6.3 is:
For convenience I used a macro scale
. The macros work as follows: You define a string, like scale = '...'
in the script above. That can be used later in any expression as @scale
(you must have set macros
enabled). The content of the scale
string is then replaced before the respective command is executed.