如何在 gnuplot 中对比较值求和

How can I sum compared values in gnuplot

扫了一眼gnuplot book但是没找到像这个比较求和的例子。如果我认为正确的话,没有多少人需要它。

我必须将它们之间的比较结果相加(绑定)并绘制为一列。例如;我必须将这些 26 的比较结果图加起来作为一列,然后将 86 的比较结果加起来作为另一个柱子。 我没有以下 01 值,我想在绘制条形图之前比较并添加 gnuplot。我们可以暂时跳过这一步,因为我做了另一个程序比较,但是求和应该是通过 gnuplot。

到目前为止我已经解释了第一步。 此外,我有一千个 26、86、12,... 随便什么。我需要一个循环,将这几千加起来,然后将下一千加起来,直到 70000。我只需要将这几千看作一个东西,就像整个图表中的支柱一样,以便进行比较。

你能帮忙吗?

S_index F_index 比较结果 绑定
2 1 0 26
2 3 0 26
2 0 0 26
1 0 0 26
3 3 1 26
2 3 0 26
0 0 1 26
0 3 0 26
0 0 1 26
2 3 0 26
3 3 1 26
0 3 0 86
0 0 1 86
0 0 1 86
0 0 1 86
2 0 0 86
1 3 0 86
3 3 1 86
3 2 0 86
0 3 0 86

添加了 csv 文件样本的数据

2,0,28
 2,1,28
 0,3,28
 2,1,28
 3,3,28
 1,3,28
 1,1,28
 1,0,28
 2,2,28
 2,3,28
 0,1,28
 1,2,28
 0,3,28
 0,0,28
2,3,88
 2,2,88
 3,2,88
 3,2,88
 1,3,88
 2,2,88
 3,0,88
 1,3,88
 3,3,88
 0,0,88
 2,0,88
 1,2,88
 0,1,88
 3,0,88
 3,0,88
1,3,110
 1,2,110
 1,3,110
 3,2,110
 2,2,110
 0,0,110
 3,3,110
 3,2,110
 2,0,110
 2,1,110
 0,1,110
 2,0,110
 0,3,110
 0,2,110
 3,2,110
 0,3,110
 1,0,110
 2,1,110
 1,3,110
 1,3,110
 2,3,110
 3,1,110
 0,0,110
 2,1,110
 1,0,110
 0,1,110
 1,1,110
 3,3,110
 0,1,110
 1,3,110
### sum up for certain conditions
reset session

set offset 0,0,0.5,0    # <left>,<right>,<top>,<bottom>
set boxwidth 0.5
set style fill solid 0.5

set table $SumUp
    plot "boundary.csv" u 3:(==) smooth freq
unset table

set yrange[0:]
set grid x,y

plot $SumUp u 0:2:xtic(1) w boxes title "Sum"

### end of code

获取错误

plot "boundary.csv" u 3:(==) smooth freq
                                            ^
         "gnuplot.gp" line 9: x range is invalid
gnuplot -v

    G N U P L O T
    Version 5.4 patchlevel 1    last modified 2020-12-01 

    Copyright (C) 1986-1993, 1998, 2004, 2007-2020
    Thomas Williams, Colin Kelley and many others

    gnuplot home:     http://www.gnuplot.info
    faq, bugs, etc:   type "help FAQ"
    immediate help:   type "help"  (plot window: hit 'h')

Terminal type is now 'qt'
unrecognized option -v

我仍然不确定我是否理解您要查找的内容。 下面的代码总结(计算)column1 等于 column2 的次数,并对 column3 中的每个值分别执行此操作。在 gnuplot 控制台检查 help smoothhelp table.

代码:

### sum up for certain conditions
reset session

$Data <<EOD
1   1   26   # <-- will be summed up
0   1   26
1   1   26   # <-- will be summed up
3   3   26   # <-- will be summed up
2   1   26
1   0   26
1   1   86   # <-- will be summed up
0   0   86   # <-- will be summed up
2   1   86
1   3   86
3   1   86
1   0   86
0   1   12
3   3   12   # <-- will be summed up
3   2   12
2   2   12   # <-- will be summed up
0   0   12   # <-- will be summed up
1   1   12   # <-- will be summed up
EOD

set offset 0,0,0.5,0    # <left>, <right>, <top>, <bottom>
set boxwidth 0.8
set style fill solid 0.5

set table $SumUp
    plot $Data u 3:(==) smooth freq
unset table

set yrange[0:]
set grid x,y

plot $SumUp u 0:2:xtic(1) w boxes title "Sum"

### end of code

结果: