【发布时间】:2014-10-30 23:47:36
【问题描述】:
这是我的 gnuplot 脚本:
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
对于输入文件:
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
生成如下图:
如何使 xlabel“利用率”比“1.7”标签低一点?使用 offset 将两个标签一起移动。
【问题讨论】:
-
@Christoph 和 @andyras 的答案都有效,但我喜欢前者,因为它很优雅,如果我使用
\n并添加标签,后者会增加太多空间(整行),与 xlabel 相比,我必须增加bmargin才能使标签完全显示。
标签: alignment gnuplot histogram