我做了一個非常簡單的測試之間我自己的例程計算直方圖(寫在IDL)和一個與gnuplot計算。Gnuplot直方圖與框不同的結果
clear
reset
width=0.02
set terminal pngcairo size 800,500 enhanced font 'Verdana,14'
set output "GNUvsMY.png"
set boxwidth width
set style fill transparent solid 0.5 border #fillstyle
set grid
set ytics 0.,5,40
set xrange [-0.09:0.09]
set yrange [0:40]
set xlabel "x"
set ylabel "Frequency [N]"
##########
hist(x,width)=width*floor(x/width)+width/2.0
#########
plot "randomIDL.dat" u 2:1 w boxes lc rgb "blue" title 'test3 my hist',\
"random.dat" u (hist($1,width)):(1.0) smooth freq w boxes lc rgb "red" title 'test3 GNU shift'
爲了使測試非常簡單,我在每個bin中生成特定數量的對象(bin寬度等於0.02)。這樣我就可以完美地瞭解每個垃圾箱中有多少物品。
現在我計算IDL程序中的bin,以便它計算最小值和最大值內的數字,並且實際上它會根據我的需要計算它們。但是當我嘗試使用gnuplot的hist
函數時,我可以重現我的IDL直方圖的(正確)結果。我附上您可以在其中找到的對象在每個箱數和random.dat文件中,你發現所有的對象randomIDL.dat(這是文件傳遞給GNUPLOT hist
)
在這裏,不同的輸出:
此外,如果我移動hist(x,width)
函數,我可以重現正確的IDL直方圖。
我紅色的帖子:Histogram using gnuplot?,但我無法理解如何告訴GUNplot如何正確地移動裏面的元素的最小和最大值。