【问题标题】:xlabel overlap in clustered histogram in gnuplotgnuplot中聚集直方图中的xlabel重叠
【发布时间】: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


【解决方案1】:

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

set style histogram rowstacked title offset 0,1

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

【讨论】:

    【解决方案2】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 2016-12-19
      • 1970-01-01
      • 2020-05-16
      • 2018-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多