2018年10月9日 星期二

Histogram by gnuplot

http://gnuplot-surprising.blogspot.com/2011/09/statistic-analysis-and-histogram.html
histogram.gp
reset
n=100 #number of intervals
max=3. #max value
min=-3. #min value
width=(max-min)/n #interval width
#function used to map a value to the intervals
hist(x,width)=width*floor(x/width)+width/2.0
set term png #output terminal and file
set output "histogram.png"
set xrange [min:max]
set yrange [0:]
#to put an empty boundary around the
#data inside an autoscaled graph.
#set offset graph 0.05,0.05,0.05,0.0
set xtics min,(max-min)/5,max
set boxwidth width*0.9
set style fill solid 0.5 #fillstyle
set tics out nomirror
set xlabel "x"
set ylabel "Frequency"
#count and plot
plot "data.dat" u (hist($1,width)):(1.0) smooth freq w boxes lc rgb"green" notitle

data.dat:
-1.8897
0.5272
-1.3683
-1.7219
0.126
-0.1471
.
.
.
Result:


X axis divided to 10 or 5
set xtics min,(max-min)/10,max                           set xtics min,(max-min)/5,max


實際應用:
1.執行grep_data
grep '|ocv_delay |' comparison.txt | grep '|<' > ocv_delay
cat ocv_delay | awk '{FS="|";print $6;}' > ocv_diff
cat ocv_diff | awk -f max_min.awk

2.將max_min.awk找出的最大/最小值填入 histogram.gp 中
reset
n=100 #number of intervals
max=0.143540 #max value
min=-0.189952 #min value

3.執行histogram.gp
gnuplot histogram.gp
4.用看圖軟體看histogram.png

沒有留言:

張貼留言

標籤