【问题标题】:How create less bins in histogram如何在直方图中创建更少的 bin
【发布时间】:2018-11-06 06:55:57
【问题描述】:

如何在 gnuplot 的直方图中设置更少的 bin?

这是此直方图的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" 

【问题讨论】:

  • 您使用什么编程语言?添加适当的语言标签
  • 对不起,我用的是gnuplot。

标签: gnuplot histogram


【解决方案1】:

使用 Philipp K Janert 的书“Gnuplot In Action”(第 256f 页)和this 网络示例,我为您想出了如下解决方案(源文件中的 cmets):

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

产生

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-03
    • 1970-01-01
    • 1970-01-01
    • 2017-07-27
    • 1970-01-01
    • 1970-01-01
    • 2022-08-12
    • 2016-02-01
    相关资源
    最近更新 更多