Как создать меньше бинов в гистограмме - PullRequest
0 голосов
/ 06 ноября 2018

Как я могу установить меньше бинов на этой гистограмме в gnuplot?

Вот данные http://leteckaposta.cz/514785176 для этой гистограммы.

Спасибо

clear
reset
f(x)=a*exp((-(x-b)**2)/(2*c**2))
a=27.3634;
b=131.12;
c=11.0518;
set key off
set border 3
set yzeroaxis
set boxwidth 0.3 absolute
set style fill solid 1.0 noborder

bin_width = 0.1;

bin_number(x) = floor(x/bin_width)

rounded(x) = bin_width * ( bin_number(x) + 0.5 )
set ytics nomirror font "Times New Roman,12"
set xtics nomirror font "Times New Roman,12"
set key top right font "Times New Roman,12"
set xlabel "Počet detekcí" font "Times New Roman,12"
set ylabel "Četnost" font "Times New Roman,12"
plot [95:175] 'poisson.txt' using (rounded($1)):(1) smooth frequency with boxes title "Naměřeno", f(x) title "Gaussova křivka" 

1 Ответ

0 голосов
/ 06 ноября 2018

Используя книгу Филиппа К. Джанерта "Gnuplot In Action" (стр. 256f) и этот образец сети, я нашел решение для вас, как показано ниже (комментарии в исходном файле):

f(x)=a*exp((-(x-b)**2)/(2*c**2))
a=27.3634;
b=131.12;
c=11.0518;

stats 'poisson.txt' nooutput        # produces statistics about the datafile
N = STATS_records                   # number of records in the file

set key off
set border 3
set yzeroaxis
set boxwidth 0.8 absolute           # set the width of your boxes
set style fill solid 1.0 noborder

bin_width = 2                       # controls the number of boxes / bins
bin(x, s) = s*int(x/s)              # normalising

set ytics nomirror font "Times New Roman,12"
set xtics nomirror font "Times New Roman,12"
set key top right font "Times New Roman,12"
set xlabel "Počet detekcí" font "Times New Roman,12"
set ylabel "Četnost" font "Times New Roman,12"
plot 'poisson.txt' u (bin($1,bin_width)):((N/2)/N) smooth freq title "Naměřeno" w boxes, f(x) title "Gaussova křivka"
                                   # ((N/2)/N) controls the height of your boxes

, что дает

enter image description here

...