2014-10-30 51 views
1

這裏是我的gnuplot腳本:xlabel在集羣直方圖重疊的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「Utilization」比「1.7」標籤稍微低一點?使用offset將兩個標籤移動到一起。

+0

兩個@克里斯托夫的和@ andyras的答覆工作,但我喜歡前者,因爲它是優雅和後者增加了太多的空間(整行),如果我使用了'\ n',並且添加了一個標籤,而不是xlabel,我不得不增加標籤的'bmargin'以顯示完整。 – 2014-10-30 16:39:01

回答

3

只是轉移屬於newhistogram了一下用的標題:

set style histogram rowstacked title offset 0,1 

(腳本的其餘部分保持不變)。

enter image description here

1

我喜歡@克里斯托夫的答案,但這裏有一些其他的變通辦法:

1)您可以將xlabel更改爲"\nUtilization",這將增加一個新行和文本移動到下一個行。

2)您也可以使用常規標籤,並關閉xlabel,這可以讓更多的靈活性:

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