【问题标题】:Gnuplot histogramGnuplot 直方图
【发布时间】:2013-07-28 02:09:43
【问题描述】:

我使用

为 .dat 文件中的一些数据创建了直方图
binwidth=...
bin(x,width)=width*floor(x/width)

plot 'file' using (bin($1,binwidth) + binwidth/2):(1.0) smooth freq with boxes

但是因为我的文件有超过 1,000,000 个条目可以读取并放入不同的 bin,所以我不知道每个 bin 的确切频率/密度。我想知道频率或让它可能将频率写入文件,有人知道它是否可能吗? 我还想知道是否可以在 y 轴上绘制百分比而不是频率,例如,如果我的频率是 50,000,而我的总数是 1,000,000,那么在 y 轴上有一个百分比而不是实际频率?

谢谢

【问题讨论】:

    标签: gnuplot histogram


    【解决方案1】:

    您可以使用stats 命令获取条目数。

    stats 'file'
    binwidth=...
    bin(x,width)=width*floor(x/width)
    
    plot 'file' using (bin($1,binwidth) + binwidth/2):(1.0/STATS_records) smooth freq with boxes
    

    绘制百分比使用

    plot 'file' using (bin($1,binwidth) + binwidth/2):(100.0/STATS_records) smooth freq with boxes
    

    【讨论】:

    • 您为我节省了很多时间!非常感谢!!
    • 我还通过在线阅读找到了另一个解决方案(但它不如你提到的方便) - 对于有类似问题的人 - 'filename' binwidth = ... bin(x,width)=width *floor(x/width) set table "hist.dat" plot fname1 using (bin($1,bw)+bw/2):(1.0) smooth frequency unset table “set table”允许所有关于直方图的信息保存在文件中,在本例中为“hist.dat”
    猜你喜欢
    • 2017-08-25
    • 2016-05-27
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 2020-10-07
    • 2011-01-29
    • 1970-01-01
    相关资源
    最近更新 更多