简体   繁体   English

计算 gnuplot 中绘制点的数量

[英]Counting number of plotted points in gnuplot

The data file contains values in the following format:数据文件包含以下格式的值:

0 0 50
0 1 70
1 0 40
1 1 70
2 0 110
2 1 60
3 0 60
3 1 120
4 0 50
4 1 50
5 0 70
5 1 70

This is a code snippet from my gnuplot script:这是我的 gnuplot 脚本中的代码片段:

plot 'file' using ($3 > 100 && $2 == 0 ? $1 : 1/0): 3 with points pointtype 1,\
     'file' using ($3 > 100 && $2 == 1 ? $1 : 1/0): 3 with points pointtype 2 

Can someone suggest a way to count the number of plotted points of each pointtype?有人可以建议一种方法来计算每个点类型的绘制点数吗?

This is relatively easy to do by setting a counter, then do counter = counter + 1 when your condition is satisfied (I've removed the style for compactness):通过设置计数器,这相对容易做到,然后在满足条件时执行counter = counter + 1 (为了紧凑,我已经删除了样式):

minval = 100; count1 = 0; count2 = 0
plot 'file' using ($3 > minval && $2 == 0 ? (count1 = count1 + 1, $1) : 1/0):3, \
'file' using ($3 > minval && $2 == 1 ? (count2 = count2 + 1, $1) : 1/0):3

gnuplot> print count1, count2
1 1

minval = 50; count1 = 0; count2 = 0
plot 'file' using ($3 > minval && $2 == 0 ? (count1 = count1 + 1, $1) : 1/0):3, \
'file' using ($3 > minval && $2 == 1 ? (count2 = count2 + 1, $1) : 1/0):3

gnuplot> print count1, count2
3 5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM