2017-04-12 149 views
2

我正在使用Gnuplot創建一個情節線的直方圖,然而,情節線不適合與酒吧頭,我也想把這條線有點遠離酒吧頭。Gnuplot直方圖與情節線

enter image description here

set border 3 
set boxwidth 0.9 
set tics nomirror out scale 0.75 
set style fill solid 0.8 

plot "03.txt" using 2:xtic(1) lt rgb "#0060ad" notitle, "" using 2 smooth csplines notitle with lines ls 1, "" using 3 lt rgb "#ff6600" notitle, "" using 3 smooth csplines notitle with lines ls 2, "" using 4 lt rgb "#dd181f" notitle, "" using 4 smooth csplines notitle with lines ls 3 

更新時間:

這是數據文件:

500000  25.938   25.938  2 
1000000  52.385   52.385  4 
1500000  79.749   78.405  6.125 
2000000  152.589   100.261  12.479 
2500000  224.869   118.364  19.159 
+0

它總是更好的來發表您的數據文件(或它的一部分顯著)。我相信你可以通過調整樣條的'using'子句來達到你想要的效果,但是可以通過簡單的選擇對列2的內容產生一些影響。通過「將線條放在離杆頭稍遠的位置」,你的意思是整個樣條的垂直移動? – Joce

+0

@Joce我添加了數據文件,是的,我需要一個垂直移動來避免用杆頭粘貼繪圖線。 – Boubakr

回答

2

這應該任意列數的工作,你必須在變量N指定它們,並在調用自定義功能xbox時給它們編號。這應該用於非密集使用。您可以垂直偏移與OFFSET變曲線(以y軸的單位)

set border 3 
#number of columns to be plotted 
N=3 
#vertical offset 
OFFSET=0 
#gapwidth (set to gnuplot's default) 
GW=2 
xbox(x,i)=x+(i-N*0.5)/(N+GW) 
set boxwidth 0.9 
set tics nomirror out scale 0.75 
set style fill solid 0.8 

plot "03.txt" using 2:xtic(1) lt rgb "0060ad" notitle, \ 
     "" using 2 with histogram notitle,  \ 
     "" using (xbox($0,1)):($2+OFFSET) smooth csplines notitle with lines ls 1,  \ 
     "" using 3 lt rgb "#ff6600" notitle with histogram, \ 
     "" using (xbox($0,2)):($3+OFFSET) smooth csplines notitle with lines ls 2,  \ 
     "" using 4 lt rgb "#dd181f" notitle with histogram, \ 
     "" using (xbox($0,3)):($4+OFFSET) smooth csplines notitle with lines ls 3