两个数据文件的比较直方图,一个具有频率,另一个具有框

时间:2014-04-19 20:57:51

标签: gnuplot histogram

我有两组数据,旨在从中得出比较直方图。然而,一个是两列数据,x及其频率,第二个是单列未分类数据,gnuplot应该导出频率。我想要一个连续的直方图,但无论我在网上找到什么都有差距。

我应该怎么做?

我尝试使用以下脚本

binwidth=5 
bin(x,width)=width*floor(x/width) 
plot'data1.txt' with boxes, 'data2.txt' using (bin($1,binwidth)):(1.0) smooth freq with boxes

包含数据文件data1.txt

1 3    
5 1    
7 1    

和第二个数据文件data2.txt

1    
1    
1    
5    
7    

这并没有给出预期的结果。

1 个答案:

答案 0 :(得分:0)

使用smooth frequency选项,使x中的数据单调;具有相同x值的点被具有相加的y值的单个点替换。因此,如果您将第一列用作x值而使用1作为y值,则可以获得计数:

plot 'secondfile.dat' using 1:(1) smooth frequency with linespoints

enter image description here

绘图风格几乎与绘图风格无关,因此您可以使用点,线,框等。