Thanks to the question gnuplot rowstacked histogram: how to put sum above bars and its answer, I learned how to add the sum of stacked histograms above their bars. However, I can't figure out how to achieve this with stacked histograms that are clustered. As shown in the below code, I can get the sum which seem to be placed at the right y coordinates.
Unfortunately, I don't know how to change the x coordinates for the second and third clusters, so they end up overlapping the first cluster's sum labels. What do I need to do to change the x coordinates of the sums so that they appear over the correct bars?
set term png size 1200, 500
set output "graph.png"
set datafile separator ","
set boxwidth 0.5
set style fill solid
set style data histograms
set style histogram rowstack
set offset -1.3,-0.3,100,0
set yrange [*:*] noextend
set xrange [*:*] noextend
set key outside
set key right top
set ylabel "Time (ms)"
set xtics font ", 10"
plot newhistogram at 0, "a.csv" u 2:xtic(1) t "Download" lc 1, \
'' u 3:xtic(1) t "Transfer" lc 2, \
'' u 4:xtic(1) t "Return" lc 3, \
'' u 5:xtic(1) t "Processing" lc 4, \
'' u 6:xtic(1) t "Wait" lc 5, \
'' u 7:xtic(1) t "Overhead" lc 6, \
'' u 0:($2+$3+$4+$5+$6+$7):(sprintf('%d', $2+$3+$4+$5+$6+$7)) not with labels offset 0,0.7, \
newhistogram at 3, "b.csv" u 2:xtic(1) t "" lc 1,\
for [i=3:7] '' u i:xtic(1) t "" lc (i - 1), \
'' u 0:($2+$3+$4+$5+$6+$7):(sprintf('%d', $2+$3+$4+$5+$6+$7)) not with labels offset 0,0.7, \
newhistogram at 6, "c.csv" u 2:xtic(1) t "" lc 1,\
for [i=3:7] '' u i:xtic(1) t "" lc (i - 1), \
'' u 0:($2+$3+$4+$5+$6+$7):(sprintf('%d', $2+$3+$4+$5+$6+$7)) not with labels offset 0,0.7
Data files:
a.csv
Device,Download,Transfer,Return,Processing,Wait,Overhead Find X2 Pro,350,0,0,287,1,24 OnePlus 8,350,29,19,410,30,138
b.csv
Device,Download,Transfer,Return,Processing,Wait,Overhead Find X2 Pro,350,0,0,293,1,26 Pixel 6,350,81,21,216,100,228
c.csv
Device,Download,Transfer,Return,Processing,Wait,Overhead Pixel 6,350,0,0,436,2,43 Pixel 3,350,140,46,187,52,206