Reputation: 3075
Here is my gnuplot script:
set terminal pngcairo font "arial,10" fontscale 1.0 size 500, 350
set output 'hist.png'
set border 3 front linetype -1
set boxwidth 0.8 absolute
set style fill pattern
set grid nopolar
set key top left reverse
set style histogram rowstacked
set style data histograms
set xtics nomirror font ",8"
set ytics 2 nomirror norotate autojustify
set ylabel font ",18" "Number of pieces used"
set xlabel font ",18" "Utilization" offset 0,-2
plot newhistogram "1.3", 'input.data' using 2:xtic(1) t "used" lc rgbcolor "black" lt 1 fs pattern 4, '' u 3 t "usable" lc rgbcolor "black" lt 1 fs pattern 1, '' u 4 t "wasted" lc rgbcolor "black" lt 1 fs pattern 3, \
newhistogram "1.5", '' u 5:xtic(1) notitle lc rgbcolor "black" lt 1 fs pattern 4, '' u 6 notitle lc rgbcolor "black" lt 1 fs pattern 1, '' u 7 notitle lc rgbcolor "black" lt 1 fs pattern 3, \
newhistogram "1.7", '' u 8:xtic(1) notitle lc rgbcolor "black" lt 1 fs pattern 4, '' u 9 notitle lc rgbcolor "black" lt 1 fs pattern 1, '' u 10:xtic(1) notitle lc rgbcolor "black" lt 1 fs pattern 3, \
newhistogram "1.8", '' u 11:xtic(1) notitle lc rgbcolor "black" lt 1 fs pattern 4, '' u 12 notitle lc rgbcolor "black" lt 1 fs pattern 1, '' u 13:xtic(1) notitle lc rgbcolor "black" lt 1 fs pattern 3, \
newhistogram "2.0", '' u 14:xtic(1) notitle lc rgbcolor "black" lt 1 fs pattern 4, '' u 15 notitle lc rgbcolor "black" lt 1 fs pattern 1, '' u 16:xtic(1) notitle lc rgbcolor "black" lt 1 fs pattern 3
for the input file:
A 16 0 0 18 1 0 18 0 3 14 1 8 10 5 10
B 16 0 0 17 2 0 15 6 0 9 14 0 0 25 0
C 16 0 0 18 1 0 19 2 0 12 11 0 2 23 0
It generates the following figure:
How can I make the xlabel "Utilization" be a little lower than the "1.7" label? Using offset
moves both labels together.
Upvotes: 1
Views: 1435
Reputation: 15930
I like @Christoph's answer, but here are a couple of other workarounds:
1) You can change the xlabel to "\nUtilization"
, which will add a newline and move the text to the next row.
2) You can also use a regular label and turn off the xlabel, which can allow more flexibility:
unset xlabel
set label "Utilization" at graph 0.5,0.1 font ",18"
Upvotes: 1
Reputation: 48430
Just shift the titles belonging to the newhistogram
up a bit with:
set style histogram rowstacked title offset 0,1
(the rest of the script remains unchanged).
Upvotes: 4