gnuplot中聚类直方图中的xlabel重叠

时间:2014-10-30 15:20:19

标签: alignment gnuplot histogram

这是我的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

它生成以下图:

enter image description here

如何制作xlabel"利用率"比......" 1.7"标签?使用offset将两个标签移动到一起。

2 个答案:

答案 0 :(得分:4)

只需将属于newhistogram的标题向上移动:

set style histogram rowstacked title offset 0,1

(脚本的其余部分保持不变)。

enter image description here

答案 1 :(得分:1)

我喜欢@Christoph的回答,但这里有几个其他的解决方法:

1)您可以将xlabel更改为"\nUtilization",这将添加换行符并将文本移动到下一行。

2)您也可以使用常规标签并关闭xlabel,这样可以提供更大的灵活性:

unset xlabel
set label "Utilization" at graph 0.5,0.1 font ",18"