2011-02-14 56 views
3

我是gnuplot的新手,並且正在嘗試爲項目創建堆疊直方圖。我遇到的問題是,我無法將ticlabels放在x軸上(即使我可以,它們也沒有以整齊的方式進行格式化)。我的GP文件如下:Gnuplot:xtics - 在tics處放置字符串

這裏是我的數據文件的快照:

CC P1-X P1-Y P2-X P2-Y 
1 0.1097586 0.3262812 1.980848 5.9098402 
2 0.1010986 0.2988812 0.9966702 5.8378412 
3 0.4017474 0.7559452 4.41813 11.7404132 
4 0.1028442 0.2974772 1.418744 6.0554552 
5 0.1097316 0.3216112 1.967492 5.8007364 
6 0.954794 0.3004874 0.9568386 5.778537 

這裏是我的GP文件:

set title "GCC compilation option by average execution time as stacked histogram" 
set terminal jpeg medium 
set output "histosmalldata.jpeg" 
set boxwidth 0.9 absolute 
set style fill solid 1.00 border -1 
set key autotitle columnheader 
set key outside right top vertical Left reverse enhanced autotitles columnhead nobox 
set key invert samplen 4 spacing 1 width 0 height 0 
set style histogram rowstacked title offset character 0, 0, 0 
set style data histograms 
set xtics border in scale 1,0.5 nomirror rotate by -45 offset character 0, 0, 0 
set xtics norangelimit 
set xtics ("O2-ffast-math-finline-functions" 1, "O2-funroll-loops-march=barcelona-ffast-math-finline-functions" 2, "GCCFLAGS_O0" 3, "O2-ftree-vectorize-funroll-loops-march=barcelona" 4, "GCCFLAGS_O2" 5, "O2-ftree-vectorize-funroll-loops-ffast-math" 6) 
set xtics 1,6 nomirror 
set ytics 0,100 nomirror 
set ytics 1 
set yrange [0:20] 
set ylabel "Time" 
set xlabel "GCC Compiler Options" 
plot 'smalldata' using 2:xtic(1) ti col, '' using 3 ti col, '' using 4 ti col, '' using 5 ti col 

這是曲線圖的圖像: enter image description here

現在,在X軸上,我有我不想要的1,2,3 - 6,相反,我想爲1等「O2-ffast-math-finline-functions」整齊地形成完美的方式。

我寫這個劇本從gnuplot的頁面諮詢一些例子後,不具備的一些動詞有很好的理解,所以除了解決方案,任何一般性評論,歡迎選購。

謝謝
薩揚

回答

3

指定後,你想要什麼你應該不會覆蓋您xtics設置。

把所有的選項到一個單一的set命令:

set xtics border in scale 1,0.5 nomirror rotate by -45 offset character 0, 0, 0\ 
     norangelimit\ 
     ("O2-ffast-math-finline-functions" 1,\ 
      "O2-funroll-loops-march=barcelona-ffast-math-finline-functions" 2,\ 
      "GCCFLAGS_O0" 3, "O2-ftree-vectorize-funroll-loops-march=barcelona" 4,\ 
      "GCCFLAGS_O2" 5, "O2-ftree-vectorize-funroll-loops-ffast-math" 6) 

注意,您可以用反斜槓作爲該行的最後一個字符逃脫換行符。

+0

謝謝你,但即使將所有xtics報表後,圖表仍然幾乎是相同的帶有一個異常時,我嘗試運行該腳本:第22行:警告:難以爲xtic標籤騰出空間....任何想法? – Sayan 2011-02-14 22:31:06

1

我想通了,我實際上並不需要,因爲這些信息是在我的源文件中指定ticlabels。 所以我修改喜歡我的源文件:

set title "GCC compilation option by average execution time as stacked histogram" 
set terminal png size 1500,1200 font "/Library/Fonts/Times New Roman Bold.ttf, 13" 
set output 'hist_gcc_1.png' 
set boxwidth 0.9 absolute 
set style fill solid 1.00 border -1 
set key outside right top vertical Left reverse enhanced autotitles columnhead nobox 
set key invert samplen 4 spacing 1 width 0 height 0 
set style histogram rowstacked title offset character 0, 0, 0 
set datafile missing '-' 
set style data histograms 
set xtics border in scale 1,0.5 nomirror rotate by -45 offset character 0, 0, 0  norangelimit 
set ytics 0,100 nomirror 
set ytics 1 
set yrange [0:20] 
set ylabel "Time" 
set xlabel "GCC Compiler Options" 
plot 'data' using 2:xticlabels(1) ti col, '' using 3 ti col, '' using 4 ti col, '' using 5 ti col 

我的dat文件看起來像:

CC P1-X P1-Y P2-X P2-Y 
O2-ffast-math-finline-functions 0.1097586 0.3262812 1.980848 5.9098402 
O2-funroll-loops-march=barcelona-ffast-math-finline-functions 0.1010986 0.2988812 0.9966702 5.8378412 
GCCFLAGS_O0 0.4017474 0.7559452 4.41813 11.7404132 
...